Shapes of textboxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parul Bagadia
    New Member
    • Mar 2008
    • 188

    #1

    Shapes of textboxes

    can we have some other shapes of text boxes? or even of labels?
    I want to write in curve mode or zigzag type format?
    Is there any property or sth by which i can get this?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    no there is no such property . Try use some third party control if you can find.

    Comment

    • Parul Bagadia
      New Member
      • Mar 2008
      • 188

      #3
      what do you mean by third party control?

      Comment

      • jg007
        Contributor
        • Mar 2008
        • 283

        #4
        This is only very basic and I have pathced it together from a few googles so you can probably get something better but -

        Code:
        Public Class Form1
        
            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                Dim test As New fancytext
                test.Multiline = True
                test.Text = vbCrLf & "      Oval textbox! "
                Dim p As Graphicspath = New GraphicsPath
                Dim reg As Region
                Dim sf As New StringFormat
                p.AddEllipse(10, 0, 80, 50) '
                reg = New Region(p)
                Me.Controls.Add(test)
                test.Region = reg
                test.Location = New System.Drawing.Point(30, 30)
        
            End Sub
        
            Public Class fancytext
                Inherits RichTextBox
        
            End Class
        End Class

        Comment

        • jg007
          Contributor
          • Mar 2008
          • 283

          #5
          and just out of curiosity here is some code to create 2x oval buttons, it took a bit of time to work out how to get them to handle a click though :)


          it was quite a bit of playing to get these to work and the textbox is quite awkward as the code I have above means that if you actually try to type into it you cannot see any text that is entered outside the boundarys so as sugested you are probably better finding a control that had been written by somebody else and then you can just add it to you project in the same way as an ordinary textbox

          Code:
          Imports System.Drawing.Drawing2D
          Imports System
          Imports System.Drawing.Text
          Imports System.Drawing
          Public Class Form1
          
              Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                  Dim test As New fancytext("Test")
                  Dim test2 As New fancytext("Test2")
                  ' test.Multiline = True
                  Dim p As GraphicsPath = New GraphicsPath
                  Dim reg As Region
                  Dim sf As New StringFormat
                  p.AddEllipse(5, 20, 80, 50) '
                  reg = New Region(p)
          
                  Me.Controls.Add(test)
                  test.Text = vbCrLf & "Click me!"
                  test.Location = New System.Drawing.Point(20, 20)
                  test.Size = New System.Drawing.Size(90, 80)
                  test.Region = reg
          
                  Me.Controls.Add(test2)
                  test2.Text = vbCrLf & "Click me!"
                  test2.Location = New System.Drawing.Point(100, 20)
                  test2.Size = New System.Drawing.Size(90, 80)
                  test2.Region = reg
          
              End Sub
          
          
              Public Class fancytext
                  Inherits Button
          
                  Private BName As String
          
                  Public Sub New(ByVal nam As String)
                      BName = nam
                  End Sub
          
                  Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
                      MyBase.OnClick(e)
                      MsgBox(BName)
          
          
                  End Sub
          
              End Class
          
             
          End Class

          Comment

          • jg007
            Contributor
            • Mar 2008
            • 283

            #6
            ,yeah yeah I know.. I just realised that I didn't really need to create a new class and could have just changed the region on an existing control <:)

            I will leave the code there though as it could probably be amended fairly easily to actually create a control with the preset shape

            this code amends an existing label but I had to change the label to not use auto size


            Code:
            Imports System.Drawing.Drawing2D
            Imports System
            Imports System.Drawing.Text
            Imports System.Drawing
            Public Class Form1
            
                Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            
            
                 
                    Dim p As GraphicsPath = New GraphicsPath
                    Dim reg As Region
                    p.AddEllipse(0, 0, 90, 50) '
                    reg = New Region(p)
                    Label1.Region = reg
                    Label1.Text = "test"
                    Label1.BackColor = Color.Azure
                    Label1.Size = New System.Drawing.Size(100, 60)
                    Label1.AutoSize = False
                    Label1.TextAlign = ContentAlignment.MiddleCenter
            
                   
                End Sub

            Comment

            • jg007
              Contributor
              • Mar 2008
              • 283

              #7
              lol, gonna have to thank you as I have found a few interesting things trying to answer this.

              for a star shaped button -

              Code:
              Imports System.Drawing.Drawing2D
              '
              Public Class Form1
              
                  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                      Dim xPoints As Integer() = {55, 67, 109, 73, 83, 55, 27, 37, 1, 43}
                      Dim yPoints As Integer() = {0, 36, 36, 54, 96, 72, 96, 54, 36, 36}
                      Dim brush As SolidBrush = New SolidBrush(Color.DarkMagenta)
              
              
                      Dim p As GraphicsPath = New GraphicsPath
                      Dim reg As Region
                      For i = 0 To 8 Step 2
                          p.AddLine(xPoints(i), yPoints(i), xPoints(i + 1), yPoints(i + 1))
                      Next
              
              
                      reg = New Region(p)
                      Button1.Image = Nothing
              
                      Button1.Region = reg
                      Button1.Text = " Click "
                      Button1.BackColor = Color.Azure
                      Button1.Size = New System.Drawing.Size(110, 105)
                      Button1.AutoSize = False
              
                      Button1.TextAlign = ContentAlignment.MiddleCenter
              
              
              
                  End Sub
              
                  
              End Class

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                Originally posted by Parul Bagadia
                what do you mean by third party control?
                you need to use componenets from vendors other than MS.

                Comment

                Working...