Delete button cannot function

Hi all,

if we try to type something on the cell, and try to press delete button, there is nothing happen. i have attached simple program to replicate my issue.

regards,
wirawan

WindowsApplication94.zip

2 Replies

AD Administrator Syncfusion Team December 20, 2006 10:22 AM UTC

Hi Wirawan,

If you want to handle the "Delete" Key stroke in a grid cell, you need to handle the CurrentCellKeyDown event of the grid. Here is a code snippet to show this.

private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Delete )
{
GridDataBoundGrid _grid = sender as GridDataBoundGrid;
GridCurrentCell _currentCell = _grid.CurrentCell;
if( _currentCell.IsEditing)
{
GridTextBoxCellRenderer _Renderer = _currentCell.Renderer as GridTextBoxCellRenderer;
if( _Renderer != null)
{
e.Handled = true;
int iSelectionLength = _Renderer.TextBox.SelectionLength;
_Renderer.TextBox.SelectionLength = iSelectionLength > 0 ? iSelectionLength : 1;
_Renderer.TextBox.SelectedText = String.Empty;
}
}
}
}

Please refer to the attached sample for more details.
WindowsApplication94.zip

Best Regards,
Haneef


NW Ngurah Wirawan December 21, 2006 01:18 AM UTC

Thanks Haneef, it's working.

Loader.
Up arrow icon