最近一直在弄第三方控件DevExpress,在gridcontol中嵌套进复选框,却只能单选,为了解决此问题在网上查了相关资料,并结合项目情况,最终得以解决
1、在GridView中某列中添加进复选框,相关的数据绑定设置成0或1进行绑定。
2、添加事件(此代码为转载)
private void repositoryItemCheckEdit2_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
{
string val = "";
if (e.Value != null)
{
val = e.Value.ToString();
}
else
{
val = "True";//默认为选中
}
switch (val)
{
case "True":
e.CheckState = CheckState.Checked;
break;
case "False":
e.CheckState = CheckState.Unchecked;
break;
case "Yes":
goto case "True";
case "No":
goto case "False";
case "1":
goto case "True";
case "0":
goto case "False";
default:
e.CheckState = CheckState.Checked;
break;
}
e.Handled = true;
}
3、这样就可以解决repositoryItemCheckEdit不能多选的问题
1、在GridView中某列中添加进复选框,相关的数据绑定设置成0或1进行绑定。
2、添加事件(此代码为转载)
private void repositoryItemCheckEdit2_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
{
string val = "";
if (e.Value != null)
{
val = e.Value.ToString();
}
else
{
val = "True";//默认为选中
}
switch (val)
{
case "True":
e.CheckState = CheckState.Checked;
break;
case "False":
e.CheckState = CheckState.Unchecked;
break;
case "Yes":
goto case "True";
case "No":
goto case "False";
case "1":
goto case "True";
case "0":
goto case "False";
default:
e.CheckState = CheckState.Checked;
break;
}
e.Handled = true;
}
3、这样就可以解决repositoryItemCheckEdit不能多选的问题