Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need to move a curve by drag it using mouse down event. How do i subscribe for this event if the curve is generated dynamically in the code (I mean I don't add it in the design as a control).

I wrote this function
VB
Private Sub zgc_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        Dim p As PointF
        p = e.Location
        Dim x, y As Double
        If e.Button = Windows.Forms.MouseButtons.Left Then
            '..........
        End If

    End Sub


but it works when I click in any position in the form EXCEPT the graph :"(

Thank you in advanced,
Arwa
Posted
Updated 2-Nov-17 21:56pm
Comments
RoRoi 2-Dec-11 10:26am    
I forgot to say that this ZedGraph is in a tabpage
Member 11882712 7-Aug-15 12:18pm    
Is there any solution for this problem? :(

1 solution

Hi Arwa, you can subscibe your handler routine to the MouseDownEvent.

This is a snippet of the code I used:

public Form1()
{
     InitializeComponent();
     ...

     ZedGraphControl1.MouseDownEvent += ZedGraphControl1_MouseDownEvent;
}

private bool GraphControl_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
{
     Console.WriteLine("Mouse Down event");

     // Your code ...

     return true;
}
 
Share this answer
 
Comments
Kats2512 3-Nov-17 10:32am    
Doubt that the person would still be looking for an answer 7 years later!
Richard Deeming 6-Nov-17 15:01pm    
I would normally agree. But in this case, there was no other solution posted; and at least one other member was looking for a solution as recently as 2015. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900