문제

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