vb.net Code:
Public Class Form2
Private Sub Form2_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
TextBox1.Multiline = True
TextBox1.WordWrap = False
End Sub
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Button1.Click
Dim myFont As New Font(TextBox1.Font.Name, TextBox1.Font.Size)
Dim StringSize As New SizeF
Dim littleAdjustment As Integer = 1
StringSize = Me.CreateGraphics.MeasureString(TextBox1.Text.Substring(1, 1), myFont)
TextBox1.Height = StringSize.Height * (TextBox1.Lines.GetUpperBound(0) + littleAdjustment)
End Sub
End Class
How is this?