Hi All,
this is my code to store multiple selected item from a list box in windows application and I am geting error.
Already i have declared array size.
string[] ItemArray = new string[20];
for (int i = 0; i <= listBox1.SelectedItems.Count; i++)
{
txtmessage.Text = ((DataRowView)listBox1.SelectedItem).Row.ItemArray[i].ToString();
}
Please help me
Thanks
Loading
Bryian TanPosted Feb 10, 2010, 2:25 AM
You have to subtract one from the count, because 0 to 19 = 20 counts
string[] ItemArray = new string[20];
for (int i = 0; i <= listBox1.SelectedItems.Count - 1; i++)
{
txtmessage.Text = ((DataRowView)listBox1.SelectedItem).Row.ItemArray[i].ToString();
}
Thanks,
Bryian Tan
Bryian TanPosted Feb 10, 2010, 9:26 AM
What is the relationship between the listbox1, ItemArray and the DataView?
Anish KhanPosted Feb 10, 2010, 4:18 AM
Your answer is good...
But listBox1.SelectedItems.Count is < 5
and also I am geting error..
Thanks
Anish