473,395 Members | 1,613 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,395 software developers and data experts.

Writing to a Multiline Textbox programmatically


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 strings which I want to
"paste" into a multiline textbox. Any ideas?
--
Anil Gupte
www.keeninc.net
www.icinema.com
Sep 7 '07 #1
7 15372
On Sep 7, 7:36 am, "Anil Gupte" <anil-l...@icinema.comwrote:
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 strings which I want to
"paste" into a multiline textbox. Any ideas?

--
Anil Guptewww.keeninc.netwww.icinema.com
You mean something like this:

//////////////
Dim strings As String() = {"one", "two", "three", "four"}

For Each s As String In strings
Me.TextBox1.Text += s
Me.TextBox1.Text += Environment.NewLine
Next
//////////////

Thanks,

Seth Rowe

Sep 7 '07 #2
That does seem to work. Here is what I tried:

Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine

Just curious as to why that did not work

Thanx,
--
Anil Gupte
www.keeninc.net
www.icinema.com

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
On Sep 7, 7:36 am, "Anil Gupte" <anil-l...@icinema.comwrote:
>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 strings which I want to
"paste" into a multiline textbox. Any ideas?

--
Anil Guptewww.keeninc.netwww.icinema.com

You mean something like this:

//////////////
Dim strings As String() = {"one", "two", "three", "four"}

For Each s As String In strings
Me.TextBox1.Text += s
Me.TextBox1.Text += Environment.NewLine
Next
//////////////

Thanks,

Seth Rowe

Sep 7 '07 #3
Anil Gupte wrote:
That does seem to work. Here is what I tried:

Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine

Just curious as to why that did not work
Did it even /compile/?
If so, set Option Strict On at once!

I couldn't get this to compile; apparently, "you can't index
txtBoxSliceInfoAll because it has no default property", nor do TextBoxes
expose a property that is an array of strings making up their multi-line
content.

Build the string up with Environment.NewLine wherever you need a Line
break, just as Seth showed you:

For Each sLine As String In AllLines
txtBoxSliceInfoAll.Text = txtBoxSliceInfoAll.Text _
& sLine & Environment.NewLine
Next

or even more succinctly:

txtBoxSliceInfoAll.Text = String.Join( vbCrLf, AllLines )

HTH,
Phill W.
Sep 10 '07 #4
Thanx!

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc**********@south.jnrs.ja.net...
Anil Gupte wrote:
>That does seem to work. Here is what I tried:

Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine

Just curious as to why that did not work

Did it even /compile/?
If so, set Option Strict On at once!

I couldn't get this to compile; apparently, "you can't index
txtBoxSliceInfoAll because it has no default property", nor do TextBoxes
expose a property that is an array of strings making up their multi-line
content.

Build the string up with Environment.NewLine wherever you need a Line
break, just as Seth showed you:

For Each sLine As String In AllLines
txtBoxSliceInfoAll.Text = txtBoxSliceInfoAll.Text _
& sLine & Environment.NewLine
Next

or even more succinctly:

txtBoxSliceInfoAll.Text = String.Join( vbCrLf, AllLines )

HTH,
Phill W.

Sep 13 '07 #5
A word of warning.

Once your 'string' gets reasonably large then setting the Text property of
the TextBox control is quite slow and after doing so the content is
'positioned' at the start.

The next question is usually, how do I move to the end off the text in my
textbox programatically.

After setting the Text Property of the TextBox you could always execute:

TextBox.SelectionStart = TextBox.TextLength
TextBox.ScrollToCaret

A better way of adding multiline data to a multiline TextBox is to use the
AppendText method. When you use this method the content automatically
scrolls to the end. The only drawback is that you habe add the NewLine
yourself:

TextBox.AppendText("Some text." & Environment.NewLine)

This makes it very easy to use a multiline textbox as an on screen 'logging'
mechanism.

"Anil Gupte" <an*******@icinema.comwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
Thanx!

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc**********@south.jnrs.ja.net...
>Anil Gupte wrote:
>>That does seem to work. Here is what I tried:

Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine

Just curious as to why that did not work

Did it even /compile/?
If so, set Option Strict On at once!

I couldn't get this to compile; apparently, "you can't index
txtBoxSliceInfoAll because it has no default property", nor do TextBoxes
expose a property that is an array of strings making up their multi-line
content.

Build the string up with Environment.NewLine wherever you need a Line
break, just as Seth showed you:

For Each sLine As String In AllLines
txtBoxSliceInfoAll.Text = txtBoxSliceInfoAll.Text _
& sLine & Environment.NewLine
Next

or even more succinctly:

txtBoxSliceInfoAll.Text = String.Join( vbCrLf, AllLines )

HTH,
Phill W.

Sep 13 '07 #6
Thanx, I am going to save this message and try using it later. Since we are
on the subject, how about this little problem. Occassionally, I want to
have the entire text highlighted so the users can jut start typing and
replace the text. I could not figure out how to do that.

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Stephany Young" <noone@localhostwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
>A word of warning.

Once your 'string' gets reasonably large then setting the Text property of
the TextBox control is quite slow and after doing so the content is
'positioned' at the start.

The next question is usually, how do I move to the end off the text in my
textbox programatically.

After setting the Text Property of the TextBox you could always execute:

TextBox.SelectionStart = TextBox.TextLength
TextBox.ScrollToCaret

A better way of adding multiline data to a multiline TextBox is to use the
AppendText method. When you use this method the content automatically
scrolls to the end. The only drawback is that you habe add the NewLine
yourself:

TextBox.AppendText("Some text." & Environment.NewLine)

This makes it very easy to use a multiline textbox as an on screen
'logging' mechanism.

"Anil Gupte" <an*******@icinema.comwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
>Thanx!

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc**********@south.jnrs.ja.net...
>>Anil Gupte wrote:
That does seem to work. Here is what I tried:

Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine

Just curious as to why that did not work

Did it even /compile/?
If so, set Option Strict On at once!

I couldn't get this to compile; apparently, "you can't index
txtBoxSliceInfoAll because it has no default property", nor do TextBoxes
expose a property that is an array of strings making up their multi-line
content.

Build the string up with Environment.NewLine wherever you need a Line
break, just as Seth showed you:

For Each sLine As String In AllLines
txtBoxSliceInfoAll.Text = txtBoxSliceInfoAll.Text _
& sLine & Environment.NewLine
Next

or even more succinctly:

txtBoxSliceInfoAll.Text = String.Join( vbCrLf, AllLines )

HTH,
Phill W.


Sep 13 '07 #7
Have a look at the TextBox.SelectAll() method.
"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP04.phx.gbl...
Thanx, I am going to save this message and try using it later. Since we
are on the subject, how about this little problem. Occassionally, I want
to have the entire text highlighted so the users can jut start typing and
replace the text. I could not figure out how to do that.

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Stephany Young" <noone@localhostwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
>>A word of warning.

Once your 'string' gets reasonably large then setting the Text property
of the TextBox control is quite slow and after doing so the content is
'positioned' at the start.

The next question is usually, how do I move to the end off the text in my
textbox programatically.

After setting the Text Property of the TextBox you could always execute:

TextBox.SelectionStart = TextBox.TextLength
TextBox.ScrollToCaret

A better way of adding multiline data to a multiline TextBox is to use
the AppendText method. When you use this method the content automatically
scrolls to the end. The only drawback is that you habe add the NewLine
yourself:

TextBox.AppendText("Some text." & Environment.NewLine)

This makes it very easy to use a multiline textbox as an on screen
'logging' mechanism.

"Anil Gupte" <an*******@icinema.comwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
>>Thanx!

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc**********@south.jnrs.ja.net...
Anil Gupte wrote:
That does seem to work. Here is what I tried:
>
Dim strLine As String
Dim n As Integer = 0
For Each strLine In AllLines
txtBoxSliceInfoAll(n) = strLine
n = n + 1
Next strLine
>
Just curious as to why that did not work

Did it even /compile/?
If so, set Option Strict On at once!

I couldn't get this to compile; apparently, "you can't index
txtBoxSliceInfoAll because it has no default property", nor do
TextBoxes expose a property that is an array of strings making up their
multi-line content.

Build the string up with Environment.NewLine wherever you need a Line
break, just as Seth showed you:

For Each sLine As String In AllLines
txtBoxSliceInfoAll.Text = txtBoxSliceInfoAll.Text _
& sLine & Environment.NewLine
Next

or even more succinctly:

txtBoxSliceInfoAll.Text = String.Join( vbCrLf, AllLines )

HTH,
Phill W.


Sep 13 '07 #8

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

Similar topics

4
by: Michael C | last post by:
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...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.