DevExpress xtragrid repositoryitemcheckedit check box multi-Select solution

Source: Internet
Author: User



1. Repositoryitemcheckedit default has three states, checked, unchecked, and semi-checked (the semi-selected state is usually used in treelist if the child node under the parent node has a selected unchecked, the parent node state is semi-selected). If the column where the Repositoryitemcheckedit is located is not bound to a data source, the column is only selectable by default, and if the data source is bound, multiple selections can be made.



2. Description of the problem:






The columedit associated with the FieldName data source described above, but not only in the design function can be selected at the same time, or when selected, the other place in the grid click the mouse, select the state or become unchecked.






In the "Do you need assistance" This class is a check box, how to achieve the multi-select function, select will not click elsewhere and automatically disappear selected?
3. Workaround



At this point we need to associate an event for this field, the event code is as follows:


private void repositoryItemCheckEdit1_QueryCheckStateByValue (object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
         {
             string val = "";
             if (e.Value! = null)
             {
                 val = e.Value.ToString ();
             }
             else
             {
                 val = "False"; // default is not selected
             }
             switch (val)
             {
                 case "True":
                 case "Yes":
                 case "1":
                     e.CheckState = CheckState.Checked;
                     break;
                 case "False":
                 case "No":
                 case "0":
                     e.CheckState = CheckState.Unchecked;
                     break;
                 default:
                     e.CheckState = CheckState.Checked;
                     break;
             }
             e.Handled = true;
         } 


Next, associate the event with this check box field


 
 this.repositoryItemCheckEdit1.QueryCheckStateByValue += new DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventHandler(this.repositoryItemCheckEdit1_QueryCheckStateByValue);


Next Run the program Repositoryitemcheckedit This field can realize the multi-select function!









DevExpress xtragrid repositoryitemcheckedit check box multi-Select solution


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.