Checking for selection in listbox
I'm trying to check if a value from a list box is selected, right now if a value isn't selected and some one clicks add "I get specified argument was out of range of values". I figure maybe an if statement would work to check if anything was selected before the code is executed. Here is the code I have.
public void Add_Click(object sender, System.EventArgs e)
{
ListViewItem item = listView1.SelectedItems[0];
Form1.FileSel = textBox1.Text;
Form1.FileSize = item.SubItems[1].Text;
Form1.selected = 1;
this.Close();
}
any help would be greatly appreciated.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

MykonineRank #2,671 · 521 reputationPosted Jul 26, 2004, 10:17 AM EDT
flipnjme19 reputationPosted Jul 26, 2004, 7:21 PM EDT