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.

How to manage keyboard input

Thread ID:

Created:

Updated:

Platform:

Replies:

91111 Nov 4,2009 07:25 AM Nov 9,2009 04:41 AM Windows Forms 2
loading
Tags: Diagram
Declan O'Loughlin
Asked On November 4, 2009 07:25 AM

When a node is selected on the diagram, if the user presses the delete key the node is removed.

I have tried using the keydown event and setting e.handled = true when the keycode = delete, but that does not have any effect.

Has anyone any ideas how I might achieve this.

Declan O'Loughlin
Replied On November 4, 2009 11:53 AM

Hi,

When I did a bit more digging I found the following
1. Add a handler for EventSink_NodeCollectionChanging
2. Record the delete key press using PreviewKeyDown


AddHandler Me.dgmProcesss.Model.EventSink.NodeCollectionChanging, AddressOf EventSink_NodeCollectionChanging

Private Sub EventSink_NodeCollectionChanging(ByVal e As CollectionExEventArgs)
If deletePressed Then
e.Cancel = True
deletePressed = False
End If
End Sub

Dinesh M [Syncfusion]
Replied On November 9, 2009 04:41 AM

Hi Declan,

Thanks for the update. You can also use the following code to prevent a node from being deleted.

AddHandler diagram.Model.EventSink.NodeCollectionChanging, AddressOf EventSink_NodeCollectionChanging

Private Sub EventSink_NodeCollectionChanging(ByVal evtArg As CollectionExEventArgs)
If (evtArg.ChangeType = CollectionExChangeType.Remove) Then
evtArg.Cancel = True
End If
End Sub

Regards,
Dinesh

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.

;