How to tell if something is selected in my listbox?
-
i have a listbox and a button.. when you click on the button i want to remove what is selected in the listbox, but i need to be able to tell if something is selected in the box or not..
if (this.lvSDeduc.SelectedItems == null)
{ MessageBox.Show("You must select something to remove before clicking the remove button.");
return; }ListViewItem objItem = this.lvSDeduc.SelectedItems[0];
this doesnt work, so when it gets to the
SelectedItems[0]
i crash since there is nothing selected.. any suggestions? thanks in advance! still a newb.. cut me some slack :P -dz -
i have a listbox and a button.. when you click on the button i want to remove what is selected in the listbox, but i need to be able to tell if something is selected in the box or not..
if (this.lvSDeduc.SelectedItems == null)
{ MessageBox.Show("You must select something to remove before clicking the remove button.");
return; }ListViewItem objItem = this.lvSDeduc.SelectedItems[0];
this doesnt work, so when it gets to the
SelectedItems[0]
i crash since there is nothing selected.. any suggestions? thanks in advance! still a newb.. cut me some slack :P -dzuse this code if (this.lvSDeduc.SelectedItems.count == 0) { MessageBox.Show("You must select something to remove before clicking the remove button."); return; }ListViewItem objItem = this.lvSDeduc.SelectedItems[0]; i think it will work From Greece: Dimitris Iliopoulos dimilio@yahoo.com
-
use this code if (this.lvSDeduc.SelectedItems.count == 0) { MessageBox.Show("You must select something to remove before clicking the remove button."); return; }ListViewItem objItem = this.lvSDeduc.SelectedItems[0]; i think it will work From Greece: Dimitris Iliopoulos dimilio@yahoo.com
-
i have a listbox and a button.. when you click on the button i want to remove what is selected in the listbox, but i need to be able to tell if something is selected in the box or not..
if (this.lvSDeduc.SelectedItems == null)
{ MessageBox.Show("You must select something to remove before clicking the remove button.");
return; }ListViewItem objItem = this.lvSDeduc.SelectedItems[0];
this doesnt work, so when it gets to the
SelectedItems[0]
i crash since there is nothing selected.. any suggestions? thanks in advance! still a newb.. cut me some slack :P -dz