当用户按Shift-Delete时,我必须将当前行的ACTIVE字段设置为1。我为GridView设置了KeyDown和CustomRowFilter事件,但是我无法使用SetFocusedRowCellValue和SetRowCellValue方法将ACTIVE字段设置为1。
private void gvMain_KeyDown(object sender, KeyEventArgs e)
{
if ((e.Shift == true) && (e.KeyCode == Keys.Delete))
{
GridView gvTmp = sender as GridView;
//gvTmp.SetFocusedRowCellValue("ACTIVE", 1); //DOES NOTHING
//gvTmp.SetRowCellValue(gvTmp.FocusedRowHandle, "ACTIVE", 1); //DOES NOTHING
//gvMain.SetRowCellValue(gvMain.FocusedRowHandle, "ACTIVE", 1); //DOES NOTHING
//gvMain.SetFocusedRowCellValue("ACTIVE", 1); //DOES NOTHING
dtMain.Rows[gvTmp.GetDataSourceRowIndex(gvTmp.FocusedRowHandle)]["ACTIVE"] = 1; //OK
gvMain.RefreshData();
}
}
如何使用GridView方法将当前行的ACTIVE字段设置为1?我不想直接将值设置为数据表。