I want to show a text which inform users for a selection but the condition below spoils that. How can I handle this fact?
comboBox1.Items.Insert(0, "Please select any value"); comboBox1.SelectedIndex = 0; comboBox1.DisplayMember = "TotalName"; comboBox1.DrawMode = DrawMode.OwnerDrawVariable; comboBox1.ColumnWidths = "45;260"; comboBox1.DataSource = deneme;
I saw combobox's dataSource when bind data starts zero and spoil my text. Below MessageBox line showed me that so.
sbyte byteCounter = 0; private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { byteCounter = Convert.ToSByte(byteCounter + 1); if (byteCounter != 0) { btnGenerate.Visible = true; string actualSelectedText; actualSelectedText = comboBox1.GetItemText(comboBox1.SelectedItem); int index = actualSelectedText.IndexOf(' '); splitchar = actualSelectedText.Substring(0, index); } else { btnGenerate.Visible = false; } igetRecordID = comboBox1.SelectedIndex; MessageBox.Show(igetRecordID.ToString()); }