Good time of day. There is a combobox with drop-down items. How can I disable an item? (that is, that it is shown in the list, and it was impossible to select it, you do not need to delete the item).

    1 answer 1

    In the properties of the ComboBox, set DrawMode to OwnerDrawFixed, after these two events:

    Font myFont = new Font("Tahoma", 10, FontStyle.Regular); private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == 1)//Отключение элемента на основе индекса { e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), myFont, Brushes.LightGray, e.Bounds); } else { e.DrawBackground(); e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), myFont, Brushes.Black, e.Bounds); e.DrawFocusRectangle(); } } void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //если выбранный индекс=1 нельзя выбирать if (comboBox1.SelectedIndex == 1) comboBox1.SelectedIndex = -1; }