ss7thirty
Well-known member
I need to create a text box that adjusts to the font as it is typed. I have some code but it only works assuming that all letters are the same size.
I need to figure out how to find the size of a specific character or another way to go about expanding a text box to make all the font typed visible until the text box reaches a certain size.
Private Sub t_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t.TextChanged
Dim sing AsSingle = t.Font.SizeInPoints
Dim accum AsInteger = 0
For Each c As Char In t.Text.ToCharArray
If accum > t.Width Then
End Sub
I need to figure out how to find the size of a specific character or another way to go about expanding a text box to make all the font typed visible until the text box reaches a certain size.
Private Sub t_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t.TextChanged
Dim sing AsSingle = t.Font.SizeInPoints
Dim accum AsInteger = 0
For Each c As Char In t.Text.ToCharArray
accum += sing
Next
If accum > t.Width Then
t.Width = accum + 5
ElseIf accum < 50 Then
t.Width = 50
ElseIf accum < t.Width Then
t.Width = accum + 5
EndIf
End Sub