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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable Delete Key in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

50480 Oct 12,2006 10:31 AM UTC Oct 12,2006 01:01 PM UTC WinForms 2
loading
Tags: GridControl
Simon Kakon
Asked On October 12, 2006 10:31 AM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;