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);
}

VulpesRank #55 · 29.2K reputationPosted May 22, 2012, 7:06 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted May 22, 2012, 7:10 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 22, 2012, 7:14 AM EDT
listBox1.Items.AddRange(richTextBox1.Lines);
Glenn PattonRank #6,159 · 275 reputationPosted May 22, 2012, 7:19 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 22, 2012, 7:23 AM EDT
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