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.
Unfortunately, activation email could not send to your email. Please try again.

Disable Delete Key in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

50480 Oct 12,2006 06:31 AM Oct 12,2006 09:01 AM Windows Forms 2
loading
Tags: GridControl
Simon Kakon
Asked On October 12, 2006 06:31 AM

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 08:55 AM

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 09:01 AM

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.

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.

;