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