473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multiline Textbox

Hi all,

I'm trying to add lines to a multiline textbox. Here's what I'd like to end
up with in the textbox (as an example):

Line1
Line2
Line3

I've tried a couple of methods but nothing seems to be working. Code like
this doesn't work:

s = "Line1";
TextBox1.Text += s + "\n";
s = "Line2";
TextBox1.Text += s + "\n";
s = "Line3";
TextBox1.Text += s + "\n";

I end up with:

Line1[]Line2[]Line3[]

(Where [] is presumably some funky representation of the character '\n').

I also tried to assign values to the lines as we go

TextBox1.Lines[0].Text = "Line1";
TextBox1.Lines[1].Text = "Line2";
TextBox1.Lines[2].Text = "Line3";

I get "Index Outside the Bounds of the Array."

I'm missing something simple here I'm sure. Any ideas?

Thanks,
Michael C.
Nov 16 '05 #1
4 31018
In article <6X*********************@news4.srv.hcvlny.cv.net >,
mi******************************@getridofthis.com says...
Hi all,

I'm trying to add lines to a multiline textbox. Here's what I'd like to end
up with in the textbox (as an example):

Line1
Line2
Line3

I've tried a couple of methods but nothing seems to be working. Code like
this doesn't work:

s = "Line1";
TextBox1.Text += s + "\n";
s = "Line2";
TextBox1.Text += s + "\n";
s = "Line3";
TextBox1.Text += s + "\n";

I end up with:

Line1[]Line2[]Line3[]

(Where [] is presumably some funky representation of the character '\n').

I also tried to assign values to the lines as we go

TextBox1.Lines[0].Text = "Line1";
TextBox1.Lines[1].Text = "Line2";
TextBox1.Lines[2].Text = "Line3";

I get "Index Outside the Bounds of the Array."

I'm missing something simple here I'm sure. Any ideas?

Thanks,
Michael C.


I seem to remember that there is a Multiline property for textboxes.
Have you tried setting that to true?
Nov 16 '05 #2
Hi Micheal C,

Remember to set the textbox multiline setting to true.

3 ways of coding it.

1)

textBox1.Text = "Euro 2004 Football" + Environment.NewLine + "World Cup 2006";

2)

string str1 = "Superman";
string str2 = "Spiderman";

textBox1.Text = str1 + "\r\n" + str2;

3)

string[] strArray = new string[5];
strArray[0] = "Line 1";
strArray[1] = "Line 2";
strArray[2] = "Line 3";
strArray[3] = "Line 4";
strArray[4] = "Line 5";

textBox1.Lines = strArray;

Hope it helps. Cheers.
--
Regards,
Chua Wen Ching :)
"Pollux" wrote:
In article <6X*********************@news4.srv.hcvlny.cv.net >,
mi******************************@getridofthis.com says...
Hi all,

I'm trying to add lines to a multiline textbox. Here's what I'd like to end
up with in the textbox (as an example):

Line1
Line2
Line3

I've tried a couple of methods but nothing seems to be working. Code like
this doesn't work:

s = "Line1";
TextBox1.Text += s + "\n";
s = "Line2";
TextBox1.Text += s + "\n";
s = "Line3";
TextBox1.Text += s + "\n";

I end up with:

Line1[]Line2[]Line3[]

(Where [] is presumably some funky representation of the character '\n').

I also tried to assign values to the lines as we go

TextBox1.Lines[0].Text = "Line1";
TextBox1.Lines[1].Text = "Line2";
TextBox1.Lines[2].Text = "Line3";

I get "Index Outside the Bounds of the Array."

I'm missing something simple here I'm sure. Any ideas?

Thanks,
Michael C.


I seem to remember that there is a Multiline property for textboxes.
Have you tried setting that to true?

Nov 16 '05 #3
Yes, I set the multiline property to true. Third option won't work -- the
items are being added dynamically on the fly. The "\r\n" code worked.
Thanks!

Michael C.

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:F0**********************************@microsof t.com...
Hi Micheal C,

Remember to set the textbox multiline setting to true.

3 ways of coding it.

1)

textBox1.Text = "Euro 2004 Football" + Environment.NewLine + "World Cup 2006";
2)

string str1 = "Superman";
string str2 = "Spiderman";

textBox1.Text = str1 + "\r\n" + str2;

3)

string[] strArray = new string[5];
strArray[0] = "Line 1";
strArray[1] = "Line 2";
strArray[2] = "Line 3";
strArray[3] = "Line 4";
strArray[4] = "Line 5";

textBox1.Lines = strArray;

Hope it helps. Cheers.
--
Regards,
Chua Wen Ching :)
"Pollux" wrote:
In article <6X*********************@news4.srv.hcvlny.cv.net >,
mi******************************@getridofthis.com says...
Hi all,

I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example):

Line1
Line2
Line3

I've tried a couple of methods but nothing seems to be working. Code like this doesn't work:

s = "Line1";
TextBox1.Text += s + "\n";
s = "Line2";
TextBox1.Text += s + "\n";
s = "Line3";
TextBox1.Text += s + "\n";

I end up with:

Line1[]Line2[]Line3[]

(Where [] is presumably some funky representation of the character '\n').
I also tried to assign values to the lines as we go

TextBox1.Lines[0].Text = "Line1";
TextBox1.Lines[1].Text = "Line2";
TextBox1.Lines[2].Text = "Line3";

I get "Index Outside the Bounds of the Array."

I'm missing something simple here I'm sure. Any ideas?

Thanks,
Michael C.


I seem to remember that there is a Multiline property for textboxes.
Have you tried setting that to true?

Nov 16 '05 #4
Hi Micheal C,

All of the 3 solutions works fine in my PC. Maybe some type error when i type it here. Haha!

Happy that you get it working now! :)
--
Regards,
Chua Wen Ching :)
"Michael C" wrote:
Yes, I set the multiline property to true. Third option won't work -- the
items are being added dynamically on the fly. The "\r\n" code worked.
Thanks!

Michael C.

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:F0**********************************@microsof t.com...
Hi Micheal C,

Remember to set the textbox multiline setting to true.

3 ways of coding it.

1)

textBox1.Text = "Euro 2004 Football" + Environment.NewLine + "World Cup

2006";

2)

string str1 = "Superman";
string str2 = "Spiderman";

textBox1.Text = str1 + "\r\n" + str2;

3)

string[] strArray = new string[5];
strArray[0] = "Line 1";
strArray[1] = "Line 2";
strArray[2] = "Line 3";
strArray[3] = "Line 4";
strArray[4] = "Line 5";

textBox1.Lines = strArray;

Hope it helps. Cheers.
--
Regards,
Chua Wen Ching :)
"Pollux" wrote:
In article <6X*********************@news4.srv.hcvlny.cv.net >,
mi******************************@getridofthis.com says...
> Hi all,
>
> I'm trying to add lines to a multiline textbox. Here's what I'd like to end > up with in the textbox (as an example):
>
> Line1
> Line2
> Line3
>
> I've tried a couple of methods but nothing seems to be working. Code like > this doesn't work:
>
> s = "Line1";
> TextBox1.Text += s + "\n";
> s = "Line2";
> TextBox1.Text += s + "\n";
> s = "Line3";
> TextBox1.Text += s + "\n";
>
> I end up with:
>
> Line1[]Line2[]Line3[]
>
> (Where [] is presumably some funky representation of the character '\n'). >
> I also tried to assign values to the lines as we go
>
> TextBox1.Lines[0].Text = "Line1";
> TextBox1.Lines[1].Text = "Line2";
> TextBox1.Lines[2].Text = "Line3";
>
> I get "Index Outside the Bounds of the Array."
>
> I'm missing something simple here I'm sure. Any ideas?
>
> Thanks,
> Michael C.
>
>
>

I seem to remember that there is a Multiline property for textboxes.
Have you tried setting that to true?


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The...
2
by: Enzo Marinelli | last post by:
Hello everyone I have a MultiLine TextBox, as follows <asp:TextBo Id="StreetAddress Rows="4 Runat="Server TextMode="MultiLine Width="100%"/
0
by: the friendly display name | last post by:
Hi, I have a filled multiline textbox on the site. I can scroll it with IE and Firefox, but under Opera (tested under 7.54, and Opera 8, under "identify as MSIE" and under Opera identification)...
1
by: ABC | last post by:
I tried KDNGrid's (www.knowdotnet.com) Multiline textbox column style for datagrid. It is very good but has some bug on wrong handle datagrid height that cannot display the scrollbar when a row...
1
by: Flack | last post by:
Hey guys, I have two questions regarding the vertical srollbar of a multiline textbox. 1. I have an "Ok" button that is initially disabled. I want it to be enabled when the user scrolls the...
2
by: Pieter | last post by:
Hi, Using this Multiline Combobox(http://www.vbcity.com/forums/faq.asp?fid=15&cat=ListBox%2FComboBox#TID58434), doesn't allow the user to type multi line text in the texbox-part of the...
2
by: Mike | last post by:
I am trying to write a little program for my own use using VB2005 express edition. I have a list of peoples names in a file that I read into an array of strings. I am using a multiline textbox to...
7
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of...
2
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.