We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Disable Delete Key in GDBG

Hi,
How can I disable the default behaviour of a GDBG when I press the Delete Key and when I set
the EnableRemove Property to TRUE.

Thanks.
Sim

2 Replies

AD Administrator Syncfusion Team October 12, 2006 12:55 PM UTC

Hi Sim,

You can handle the RowsDeleting event of the grid and set e.Cancel to true, to avoid the default behavior of deleting rows when delete key is pressed.

If you have set the ListBoxSelection mode and want to delete the text alone when delete key is pressed, you can follow the code below.
 
private void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e)

{
if(this.gridDataBoundGrid1.CurrentCell.IsEditing)

{
e.Cancel = true;
GridTextBoxControl tb = (GridTextBoxControl)this.gridDataBoundGrid1.CurrentCell.Renderer.Control;
if(tb.SelectionLength == 0)
tb.SelectionLength = 1;

tb.SelectedText = "";
}
}

Let me know if you have any other questions.
Regards,
Rajagopal


AD Administrator Syncfusion Team October 12, 2006 01:01 PM UTC

It works fine.
Thanks a lot.


>Hi Sim,

You can handle the RowsDeleting event of the grid and set e.Cancel to true, to avoid the default behavior of deleting rows when delete key is pressed.

If you have set the ListBoxSelection mode and want to delete the text alone when delete key is pressed, you can follow the code below.
 
private void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e)

{
if(this.gridDataBoundGrid1.CurrentCell.IsEditing)

{
e.Cancel = true;
GridTextBoxControl tb = (GridTextBoxControl)this.gridDataBoundGrid1.CurrentCell.Renderer.Control;
if(tb.SelectionLength == 0)
tb.SelectionLength = 1;

tb.SelectedText = "";
}
}

Let me know if you have any other questions.
Regards,
Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon