How to set Selectedvalue in Combobox c#
08:25 01 Jun 2017

I have one combobox in which I have set DataSource Value, but when I try to set SelectedValue, the ComboBox returns null. so please help.

BindingList> m_items =
                     new BindingList>();

for (int i = 2; i <= 12; i++)
    m_items.Add(new KeyValuePair(i.ToString(), i));
ComboBox cboGridSize = new ComboBox();
cboGridSize.DisplayMember = "Key";
cboGridSize.ValueMember = "Value";
cboGridSize.DataSource = m_items;

cboGridSize.SelectedValue = 4;

when I set SelectedValue with 4 then it returns NULL.

c#