开发者

Custom Built Combo Box Check Box

开发者 https://www.devze.com 2023-02-05 13:26 出处:网络
I have a custom built combo box check box. I have taken it from http://www.codeproject.com/KB/combobox/extending_combobox.aspx

I have a custom built combo box check box. I have taken it from http://www.codeproject.com/KB/combobox/extending_combobox.aspx

The drop down consists of 5 items, namely A, B, C, D, All.

What I wanna do is when the user checks All, uncheck A, B, C, D. and when the user select开发者_JAVA百科s, either of A, B, C, D uncheck All.

I cannot figure out which logic should i put in.

I have tried this:

int index = ComboCheck.FindString(@"All");

foreach (var x in tComboCheck.CheckBoxItems.Where(y => y.Checked))
 {
  if(x.Text.StartsWith("A"))
    {
     ComboCheck.CheckBoxItems[index].Checked = false;
    }
  if(x.Text == @"All")
    {
     x.Checked = true;
    }
 }

It does not work. I am using this code under Checked Changed event. Please help


Simpler is better.

  • Figure out what the user just did (checked "All" or checked something else)
  • If user checked "All"
    • For each other item, uncheck it
  • If user checked something else
    • Uncheck "All"

Ignore when users uncheck an item.

Don't try to lump these into one loop statement, it just gets confusing that way.

0

精彩评论

暂无评论...
验证码 换一张
取 消