Save x and y value of chart upon mouse click somewhere on the chart

mattijsstu

Member
Joined
Feb 19, 2013
Messages
15
Programming Experience
Beginner
Hi,

I was looking on the net for a solution to my problem and did not find one directly.

In visuals studio 2012 i have a program. In this program i make a chart according to some calculations. Upon finishing the chart calculations, the users gets a new window with the chart displayed on. I now need to be able to let the user us his mouse on that chart, click on the line somewhere and let it find the corresponding x and y value. When he clicks this x and y value get stored in a variable ( x1 and y1 for instance). I have found something on the internet wich looks promissing, buth i can't get my head around it, and it does not work : Support: How to display the X and Y values while doing MouseMove on the chart? : Syncfusion .

In my program, form 1 is the form where i calculate, and form 3 displays the graph/chart. So ofer the calculation it says
VB.NET:
form3.show

In this form i added the following code (start of the code in the link above):

VB.NET:
Imports System.Windows.Forms.DataVisualization.ChartingImports System.IO
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient


Public Class Form3
    Private Sub chartcontrol_mousemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseDown, Chart1.MouseUp, Chart1.MouseMove
        Dim mousepoint As Point = New Point(e.X, e.Y)
        Dim chpt As chartpoint = ChartArea.getvaluebypoint(New Point(e.X, e.Y))


    End Sub
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    End Sub
End Class

I realy hope someone can help me out, i am kinda stuck.

Thank you
 
Back
Top