How to check whether the item in the combo box is selected or not in C#?

zoya picture zoya · Mar 17, 2010 · Viewed 64.4k times · Source

I have a combo box in which I have to display the dates from a database. The user has to select a date from the combo box to proceed further, but I don't know how to make the user aware of selecting the item from the combo box first in order to proceed further.

What process should be followed so that a user can get a message if he has not selected the date from the combo?

Answer

Ashish Gupta picture Ashish Gupta · Mar 17, 2010
if (string.IsNullOrEmpty(ComboBox.SelectedText)) 
{
 MessageBox.Show("Select a date");
}