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.