How to set default item in ComboBox

How can I set a default item as selected in a ComboBox when a form loads

I tried adding "this.FilterCostOperatorComboBox.SelectedItem = 2;" to the InitializeComponent function, but when the form loads, the combobox is still blank...

I'm writing in C#/VS 2005, if it makes a difference...

Gabe


Answer this question

How to set default item in ComboBox

  • Soul 2.0

    When do you fill the combobox with items

    try using the Load event of the form



  • Bijesh

    Or .SelectedIndex = -1 to display nothing initially is handy.

     

    GS


  • jim_cool

    Is what is seen in the box numbers

    Have you set a value for each item

    Try this, using the index of the box instead....

    this.FilterCostOperatorComboBox.SelectedIndex = 0;

    This will set the box onload to the first item in the list.

    Zath


  • How to set default item in ComboBox