Visual FoxPro
Windows Vista
Game Technologies
.NET Development
Visual C#
Windows Live
Architecture
Microsoft ISV
SQL Server
Windows Forms
Visual J#
Smart Device
Visual C++
Visual Basic
Visual Studio
Software Development Network>> Windows Forms>> Read line by line
Read line by line
Hot Topic
Rows in the DataGrid automatically deleted
Minimized Windows Completely Disappear, however, they can be found in Task Manager as Active/Running programms!
HOW TO: Dynamically Add a Control Without Hardcoding the Control Type in Visual Basic .NET
VS2005: How to handle DateTime <=> DateTimePicker and NULL less verbose
Client metainfo
Linked Scrolling of 2 TextBoxes
VB2005 - Listview Column Sort
treeview "AfterSelect" runs when the form is loaded
Problem with access database in vb.net
AxSpreadsheet
Windows Forms
Max controls in controls collection of panel?
ClickOnce file extension registration
Adding buttons dynamically to a groupbox (C#)
Need to build a listbox containing a checkbox and image
Creating Toolbars similiar to MS Office
Null Dates - binding to IBindingList Objects & storing in SQL Server
Runtime exception in MDI Application
Cross object communication
How do you catch the delete event on a datagrid
Call function on Parent form
Read line by line
Hello I have a TextBox full of lines of text and now all I want to do is just read them Line by Line !
Regards
Answer this question
Read line by line
nimrodel
Doesn't look like TextBox supports that, but I know another way using the String.Split function.
public void SomeFunc()
{
string sText = MyTextBox.Text;
string delimStr = "\n";
char []delimeters = delimStr.ToCharArray();
string []AllLines = sText.Split(delimeters);
//Now AllLines has all of the lines of text from the textbox. Each line per array cell.
}
Neil Harper
Look at the TextBox.Lines properties. It returns an array on the strings which represent each line in the TextBox.
Jim Griesmer
The TextBox class has a property called Lines that gives you an array of strings, one for each line.
Here's a C# code snippet that throws each line to the string in a MessageBox:
for (int i = 0; i<this.textBox1.Lines.Length; i++)
MessageBox.Show(this.textBox1.Lines[i]);
abinaysh
Use the TextBox.Lines property.
for (int i = 0; i<this.textBox1.Lines.Length; i++)
MessageBox.Show(this.textBox1.Lines[i]);
Brad Carroll
Here is some sample code that might help you with your issue:
string[] strArray = MyTextControl.Text.Split(Environment.NewLine.ToCharArray());
foreach(string s in strArray)
{
MessageBox.Show(s);
}
Mulktide
OK, I didn't look hard enough. There is a Lines property.
string []AllLines = MyTextBox.Lines;
That would do what I was trying to achieve in the last example, in less code. It will fill the array, one text line per array cell.
Read line by line
Answer this question
Read line by line
nimrodel
public void SomeFunc()
{
string sText = MyTextBox.Text;
string delimStr = "\n";
char []delimeters = delimStr.ToCharArray();
string []AllLines = sText.Split(delimeters);
//Now AllLines has all of the lines of text from the textbox. Each line per array cell.
}
Neil Harper
Jim Griesmer
Here's a C# code snippet that throws each line to the string in a MessageBox:
for (int i = 0; i<this.textBox1.Lines.Length; i++)
MessageBox.Show(this.textBox1.Lines[i]);
abinaysh
for (int i = 0; i<this.textBox1.Lines.Length; i++)
MessageBox.Show(this.textBox1.Lines[i]);
Brad Carroll
string[] strArray = MyTextControl.Text.Split(Environment.NewLine.ToCharArray());
foreach(string s in strArray)
{
MessageBox.Show(s);
}
Mulktide
string []AllLines = MyTextBox.Lines;
That would do what I was trying to achieve in the last example, in less code. It will fill the array, one text line per array cell.