How do I code so that combo box will always selected 1st before Query

azae

Newcomer
Joined
Jan 6, 2005
Messages
18
Hello,
I am actually want to do validation on combobox.
It is like u make user must make choose one of the item from combo box before they procedd to do any other action like UPDATE, SAVE or DELETE.

In textbox, we always use IF statement
like
if (textBox1.text == "") {
//promt MsgBox ask user to input
return;
}

So, how we do if it is comboBox.
I also welcome anything similar, a least I can figure out an idea
thanks
 
Depending on how you load up/bind your combobox, you could do a check like:
Code:
if( cboSomeCombo.SelectedIndex == -1 )
{
//do your "nothing was selected" logic here
}
else
{
//continue your "good" logic, something was selected
}
 
Back
Top