Devexpress控件使用-CheckListBox(Check选中或不选是ItemCheck事件)

           //为了找到这个事件,我花了快一个小时,试了一半的事件

          // 选中或不选事件:itemCheck;

 

             //清空项
            checkedListBoxControl1.Items.Clear();

            //绑定
            checkedListBoxControl1.DataSource = dt;
            checkedListBoxControl1.ValueMember = "ID";
            checkedListBoxControl1.DisplayMember = "Name";

            //全选
            //checkedListBoxControl1.CheckAll();

            //项的个数
            int itemCount = checkedListBoxControl1.ItemCount;

            //添加项(如果设置绑定,添加项无效)
            checkedListBoxControl1.Items.Add("kk");

            //设置选中状态、显示值、实际值、是否可用(如果设置绑定,这些将会无效)
            checkedListBoxControl1.Items[0].CheckState = CheckState.Checked;
            checkedListBoxControl1.Items[0].Description = "显示值";
            checkedListBoxControl1.Items[0].Value = "实际值";
            checkedListBoxControl1.Items[0].Enabled = false;
            //效果和上面一样
            checkedListBoxControl1.SetItemChecked(0, true);
            checkedListBoxControl1.SetItemCheckState(0, CheckState.Checked);
            checkedListBoxControl1.SetItemValue("实际值",0);           

            //是否被勾选
           bool isChecked=  checkedListBoxControl1.GetItemChecked(0);
            //获取某项状态
           string checkState = checkedListBoxControl1.GetItemCheckState(0).ToString();
            //获取某项绑定值 valueMember
           string trueValue = checkedListBoxControl1.GetItemValue(0).ToString();
            //获取某项显示值   displayMember
           string disValue = checkedListBoxControl1.GetDisplayItemValue(0).ToString();
           string disValue2 = checkedListBoxControl1.GetItemText(0);

            //是否点击一次 就改变状态
           checkedListBoxControl1.CheckOnClick = true;

            //是否多列显示
           checkedListBoxControl1.MultiColumn = true;

            //checkedListboxControl 是否获得焦点
           bool isfocus=checkedListBoxControl1.ContainsFocus;

         //实现单选功能
            checkedListBoxControl1.SelectedIndexChanged += new                                                                                       

                      EventHandler(checkedListBoxControl1_SelectedIndexChanged);
          
            //获取选中项的绑定值(前提:手动添加的可以获取,但是datatable绑定的无法获取)

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值