Question : How give value to dropdown in Windows application

Hi,
   I has dropdown in windows application . If i not selecting anything from dropdown i need to show message box . but i geting object reference error
my code is

if (ddlComp.SelectedItem.ToString().Length < 1)
                 {
                     MessageBox.Show("Please select Type");
                 }

and i need to know how give values to dropdown in windows application?

Answer : How give value to dropdown in Windows application

Hi!

>>>  i need  "select type " on when open the form

Then try like this:
1:
2:
3:
4:
5:
6:
7:
private void Form1_Load(object sender, EventArgs e)
{
   comboBox1.Items.Add("Item1");
   comboBox1.Items.Add("Item2");
   comboBox1.Items.Add("Item3");
   combobox1.Text="Select Type";
}
Random Solutions  
 
programming4us programming4us