I want to set default value (rather than first one) in combobox through SelectedItem/SelectedText/SelectedValue (from any one way).
I have tried to resolve it through many different ways. Like I have set enum to Key Value Pair. Tried to use "SelectedIndex". It is showing '-1' while debugging. In other "selected*" options, value is 'null'. I do not know what is happening. I have attached code. Please take a look and help me to resolve it. Thank you.
ComboBox cmbxType= new ComboBox();
cmbxType.FormattingEnabled = true;
cmbxType.DropDownStyle = ComboBoxStyle.DropDownList;
cmbxType.Margin = new Padding(3, 6, 3, 3);
cmbxType.Name = "cmbxType";
cmbxType.Size = new System.Drawing.Size(200, 28);
cmbxType.TabIndex = 1;
cmbxType.DataSource = Enum.GetValues(typeof(StateType));
cmbxType.SelectedIndexChanged += new System.EventHandler(cmbxType_SelectedIndexChanged);
cmbxType.ValueMember = (workflowRows).ToString();
cmbxType.SelectedValue = 2
PS: I am creating this combobox after creating form and the problematic case is with enum only.