سؤال

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