Вопрос

I have a combobox with various items, item1 item2 item3

They all show as visible and are selectable, but i wanna hide for example item3, i want him to appear only when a variable equals 1

is this possible? Because all of the items i have in the collection including item3 are showing up.

I'm using the following to disable its selection

  if (ComboBox1.SelectedItem == "item3")
        {
            ComboBox1.SelectedIndex = -1;
  }

and it works fine, but i wanna actualy make item3 invisible unless other variable is set as 1

Это было полезно?

Решение

I would wait until the other variable is set and then add that item to the combo box. Something like this.

if (variable == 1) {
    ComboxBox1.Items.Add("item3");
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top