Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Listbox selected

Status
Not open for further replies.

chezealot9

Programmer
Jun 17, 2003
50
0
0
US
Hey Guys, for a listbox component, how can I check that the user has selected a row from it? I have a button and need to make sure a row is chosen before trying to process one.

Thanks for any help!!
 
If no item(s) is selected in a list box, the SelectedIndex property is -1. So this logic should work:

if(MyListBox.SelectedIndex > 0)
{
// process selected value(s)
}
else
{
// do something else
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top