Setting Wrap text for a label in VB.Net
-
Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET
-
Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET
This probably isn't the best example, but it's the only thing I could think of:
Dim StartVar As Integer = 5
Dim EndVar As Integer = Label1.Text.Length
Dim Tempstring As StringWhile Not StartVar < 5
Tempstring = Label1.Text.Insert(StartVar, ControlChars.NewLine)
Label1.Text = Tempstring
StartVar += 5
If StartVar >= EndVar Then
Exit While
End If
End WhileThis example inserts a new line every 5 characters, and then stops if it runs out of characters. Just replace
StartVar
with the number of characters you want to have on each line of your label. Hope this helps!
Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.
-
Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET
You can turn the AutoSize property off, the set the size of the label yourself. With AutoSize turned off, the label control does automatic word wrap.
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007