Yet another question, I have a large amount of data in a Rich Text Box that I am trying to copy to a List Box. Using the ListBox.Items.Add() method will pick up the text and copy it lock stock & barrel to the list box ignoring any carridge return/ line feeds in the rich text box. what I am pretty sure I need is a foreach loop to go into the richTextBox.
and each time there is a \n add the item to the listBox but I am unsure of how to format this foreach loop. I have tried :
int a = 0;
string[] Readings = Value.Split('\n');
foreach (string v in Readings)
{
a++;
listBox1.Items.Add(a);
}
string[] Readings = Value.Split('\n');
foreach (string v in Readings)
{
a++;
listBox1.Items.Add(a);
}
VulpesPosted May 22, 2012, 11:06 AM
VulpesPosted May 22, 2012, 11:23 AM
When you have 5 minutes, give this a read:
http://blogs.msdn.com/b/ericlippert/archive/2007/10/17/covariance-and-contravariance-in-c-part-two-array-covariance.aspx
Glenn PattonPosted May 22, 2012, 11:19 AM
VulpesPosted May 22, 2012, 11:14 AM
listBox1.Items.AddRange(richTextBox1.Lines);
Glenn PattonPosted May 22, 2012, 11:10 AM