Not logged in - Login

Clearing value of LookupEdit control in XtraGrid

In a DevExpress XtraGrid control, a column with a control edit of LookupEdit type can be made to clear its value by using the delete key.

Natively, the ctrl-delete combination will delete the value from the column.

To get it to work with only the delete key, do the following:

private void cbo_KeyDown(object sender, KeyEventArgs e){
   // was the Delete key pressed?
   if (e.KeyCode == Keys.Delete)
   {
      // clear the current column on the grid of any data
      this.gridViewMyGrid.SetFocusedRowCellValue(this.MyGridColumn, null);
   }
}