DEV中gridControl中新增複選框採用右鍵選單實現全選和取消全選
阿新 • • 發佈:2021-02-01
1,現在gridControl中新增複選框修改屬性使其的多選
2,在gridControl中新增右鍵選單ContextMenuStrip
3,新增右鍵選單ContextMenuStrip的點選事件
4,寫一個共用方法來修改複選框的值
private void CheckedOperation(string checkeds) { if (gvDrug.IsEmpty) return; var tbl = gcDrug.DataSource as DataTable; foreach (DataRow row in tbl.Rows) { row[colChecked.FieldName] = checkeds; } tbl.AcceptChanges(); }
全選
在這裡 private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckedOperation("True");
} 插入程式碼片
取消全選
private void rightsToolStripMenuItem_Click(object sender, EventArgs e) { CheckedOperation("False"); }