Page 1 of 1

Referrence to chosen bar on MouseMove event in VB.NET

Posted: Mon Jul 11, 2005 9:36 am
by 9637396
I want to show a text whenever the user points to a particular bar (say bar 4 of 20 bars in a bar chart) with the mouse.

In old VB the code would be: Histogram1.Series(i).GetMousePoint. This would return the ref. to the bar - with would this be translated into in VB.NET ?

Posted: Mon Jul 11, 2005 9:54 am
by narcis
Hi ext-cph,

Which TeeChart version are you using? TeeChart for .NET v1 includes VB.NET examples at the ASP.NET Server Examples. TeeChart for .NET v2 includes a live demo, also available at http://www.steema.net/TeeChartForNET/index.aspx , which includes several examples. If you have any trouble translating C# code to VB.NET you may try using http://www.kamalpatel.net/ConvertCSharp2VB.aspx .

Not quite what I wanted!

Posted: Mon Jul 11, 2005 11:26 am
by 9637396
The example is not exactly what I am looking for!

I am using the .NET v.2 and is missing a method for retrieving the number of the bar the mouse is pointing at. Like the 'old' VB way to do this: Histogram1.Series(i).GetMousePoint. Here GetMousePoint did exactly that - returning the number of the bar in the series.

What is the proper way in my MouseMove event to do this?

Posted: Tue Jul 12, 2005 8:04 am
by narcis
Hi ext-cph,

The solution should be code below but I've seen it doesn't work for Histogram series. I have added it to our defect list to be fixed for next releases. However you could use it for other series types.

Code: Select all

    Private Sub TChart1_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseMove
        Dim Index As Integer
 
        Index = TChart1.Series(0).Clicked(e.X, e.Y) 

        If Index <> -1 Then
            TChart1.Header.Text = "Bar num.: " + (Index + 1).ToString()
        End If
    End Sub