Dynamically setting textbox lines() property

euromax

Member
Joined
Apr 19, 2009
Messages
7
Location
Mauritius
Programming Experience
Beginner
Hi I'm trying to set individual lines of text in a multiline textbox at runtime using this type of code

myTextBox.lines(0)= "something"

But it isn't doing the job, for some reason I can only set the lines in the design view. No exception is being thrown since I already set the required lines() array bounds in textbox properties but the data doesnt go into the textbox.

I can't see why this shouldnt work since the property is public.
:confused:help would be much appreciated.
 
Ok I found [one] solution

This kind of code seems to work

Dim mystring() as string= {"something", "anotherthing", "whatever"}
MyTextBox.Lines= mystring

Now could someone tell me what's the point in having this circuitous pain in the a*!:mad:
 
help said:
By default, the collection of lines is a read-only copy of the lines in the TextBox.
So you have to get the array from the Lines property, modify the array, assign the modified array to the Lines property.
VB.NET:
Dim lines() As String = Me.TextBox1.Lines
lines(1) = "new line"
Me.TextBox1.Lines = lines
 
Back
Top