1. 往表格中添加repositoryItemCheckEdit1
2. 事件:
repositoryItemCheckEdit1.QueryCheckStateByValue += repositoryItemCheckEdit1_QueryCheckStateByValue;
private void repositoryItemCheckEdit1_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e){string val = "";if (e.Value != null){val = e.Value.ToString();}else{val = "False";//默认为不选 }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.Unchecked;//初始化就是不选break;}e.Handled = true;}
3. 获取有哪些行被勾选
List<string> cblist = new List<string>();for (int i= 0;i < bandedGridView1.RowCount;i++){object cellValue = bandedGridView1.GetRowCellValue(i, "FileName");if (cellValue.ToString() == "True"){cblist.Add(bandedGridView1.GetRowCellValue(i, "FileName").ToString());}}