GridControl中事件
gridView1_CellValueChanged事件在
SetRowCellValue后触发 或者编辑修改后触发
this.gridView1.SetRowCellValue(rowindex, "sqty", sumdt.Rows[0]["quantity"].ToString());
设置复选框:
SELECT CAST(0 AS BIT) ischeck private void detailGridView_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { GridView View = sender as GridView; if (e.RowHandle >= 0 && e.Column.FieldName == "ischeck") { bool value = (bool)(e.CellValue);//View.GetRowCellValue(e.RowHandle, View.Columns["ischeck"]); if (value) { View.SetRowCellValue(e.RowHandle, View.Columns["ischeck"], false); } else { View.SetRowCellValue(e.RowHandle, View.Columns["ischeck"], true); } } }
下拉枚举:
全选 取消全选:
//全选 取消全选 private void btnselectall_Click(object sender, EventArgs e) { int count = 0; // 全选 for (int i = 0; i < detailGridView.RowCount; i++) { if (!(bool)detailGridView.GetRowCellValue(i, detailGridView.Columns["ischeck"])) { detailGridView.SetRowCellValue(i, detailGridView.Columns["ischeck"], true);//选中 } else { count++; } } //取消全选 if (count == detailGridView.RowCount) { for (int i = 0; i < detailGridView.RowCount; i++) { detailGridView.SetRowCellValue(i, detailGridView.Columns["ischeck"], false);//取消选中 } } }