Need a textbox that displays all lines w/o scrolling
I can put a long text string in a label, and it will automatically adjust the size to fit the text. Unfortunately, it does not recognize carriage returns. The text box does recognize the returns, but I have to tell it how many lines I want.
Is there some way of having the best of both? Can I set a property that would accomplish this. (I could not find it, if it exists). Is there some other object that would be better?
Sorry I posted this in the wrong Place. I am dealing with ASP.net 2008
Re: Need a textbox that displays all lines w/o scrolling
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?