Hello All,
I am trying to udapte a listbox as suggested like this,but it gives me error.Please help...
No matter which item I select in the Listbox,the index ( listBox1.Items[index]) always it takes as -1. Error:::Invalid Argument = Value of '-1' is not a valid index.
but when I print the index value using Console.writeLi ne it prints the correct slected index. I am not able to figure out the reason.
Thank you all
I am trying to udapte a listbox as suggested like this,but it gives me error.Please help...
Code:
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = listBox1.SelectedIndex;
Console.WriteLine("Index is {0}",index );
listBox1.Items[index] = textBox1.Text;
}
but when I print the index value using Console.writeLi ne it prints the correct slected index. I am not able to figure out the reason.
Thank you all
Comment