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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Avoiding the deletion of a shape in a diagram when DELETE key is pressed

Thread ID:

Created:

Updated:

Platform:

Replies:

77290 Oct 23,2008 07:12 PM UTC Oct 27,2008 01:35 PM UTC WinForms 4
loading
Tags: Diagram
Administrator [Syncfusion]
Asked On October 23, 2008 07:12 PM UTC

Hello for everybody.

In the application that I am developing, the user can select any kind of shape drawn in the diagram, and then, press the DELETE key.

I have seen when I press the DELETE key and exists a shape selected, this is deleted. But I need first to detect the code of the DELETE key BEFORE of the deletion of the shape, in another words, I need the shape don't be deleted in spite of the user presses the DELETE key (the user can decide if the shape should be deleted).

I have intended to do that by using handles for the diagram's events PreviewKeyDown,KeyUp, KeyDown and Keypress, but I can't obtained the desired operation.

I wonder if you could help to me. Thanks


Ron Alan Sawyer
Replied On October 23, 2008 11:01 PM UTC

In the Key up event of the diagram component check to see if the KeyEventArgs.KeyCode is equal to Keys.Delete. Something like:

private void diagramComponent_KeyUp(object sender, KeyEventArgs e)
{
string ii;
if (e.KeyCode == Keys.Delete)
{
DoStuff();
}
}



Administrator [Syncfusion]
Replied On October 24, 2008 12:29 PM UTC

Hi RAS.

I have probed the KeyUp method, but I really need that when the user select a shape in the diagram and press the DELETE key, the shape doesn't be deleted.

Is there any form to configure the diagram for avoiding the deletion of shapes because of the press of DELETE key?

Thanks.


Ron Alan Sawyer
Replied On October 24, 2008 09:33 PM UTC

OK, I looked at this a little more closely.

On your form, set KeyPreview to true.

In your form's KeyDown event put the following code:

if (e.KeyCode == Keys.Delete)
e.Handled = true;
This will prevent the delete key from being passed to the diagram control and your symbol will not be deleted.


Administrator [Syncfusion]
Replied On October 27, 2008 01:35 PM UTC

I have probed it, and it works correctly. Tnaks


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

;