executing MouseDown then executing KeyUp (Object sender cant keep track the latest ob

karhong

Member
Joined
Jul 13, 2008
Messages
6
Programming Experience
Beginner
Hi,

I have some question to ask because I don't understand why is it happening like that.

I have 2 polygon created and displayed.
I've make mouseDown, mouseUp, mouseMove event. (For some movement for the polygon)
Now i wanted to implement keyUp(pressing delete button from keyboard, then delete the polygon)

This is the code for MouseUp:
VB.NET:
Expand Collapse Copy
Private Sub Shape_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
    isDraggingA = false
    controlALL = CType(sender,Control)
    If (e.Button = MouseButtons.Left) Then
        OB = sender
        AddHandler controlALL.KeyUp, AddressOf Me.DeleteButton
    End If
End Sub

the " object sender " is to identify which polygon I've selected
then, I've made "Shape_MouseUp" it so that it will run "DeleteButton" function

Below is my DeleteButton code:

VB.NET:
Expand Collapse Copy
Private Sub DeleteButton(ByVal sender As Object, ByVal e As KeyEventArgs)
    controlALL = CType(OB,Control)
    If (e.KeyCode = Keys.Delete) Then
        controlALL.Dispose
    End If
End Sub

PROBLEM : When i execute this 2 code, the result i got is,

when i click on polygon 1, then press 'delete' SUCCESS
But when i click on polygon 2, then press 'delete' NOTHING HAPPEN



I don't know why the function DeleteButton cannot get the polygon 2.
Any idea?
 
Last edited by a moderator:
Back
Top