第三方控制元件DevExpress.repositoryItemCheckEdit複選擇框多選的問題
阿新 • • 發佈:2019-01-03
最近一直在弄第三方控制元件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不能多選的問題