Page 1 of 1

Simple drag point example with VB .NET

Posted: Wed Oct 26, 2011 3:09 pm
by 13051218
I am reprogramming an old application in which you could drag points. I have not found anything similar to the code I was using -which I include below these lines. Could you provide a snippet on VB .NET similar to it together with other functions useful for dragging point and getting info for them?

Thanks a lot

Private Sub Tchart1_OnDragPointToolDragPoint(ByVal Index As Long)
Tchart1.ToolTipText = Format(Tchart1.Series(0).XValues.Value(Index), "dd/mm/yyyy hh:nn") & " " & _
Format(Tchart1.Series(0).YValues.Value(Index), "#,###,##0.000")
End Sub

Re: Simple drag point example with VB .NET

Posted: Thu Oct 27, 2011 1:05 pm
by 10050769
Hello Yacu,

I have made a simple example where I have gotten the values of Series in the Event Drag of DragPoint Tool and I recommend you try to do something as next:

Code: Select all

Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        InitializeChart()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private dragpoint As Steema.TeeChart.Tools.DragPoint
    Private series1 As Steema.TeeChart.Styles.Points
    Private Sub InitializeChart()
        series1 = New Points(TChart1.Chart)

        Dim rnd As New Random()
        Dim data As DateTime = DateTime.Now
        Dim day As TimeSpan = TimeSpan.FromDays(1)
        series1.XValues.DateTime = True
        For i As Integer = 0 To 9
            series1.Add(data, rnd.[Next](100))

            data += day
        Next
        TChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoDays)
        dragpoint = New Steema.TeeChart.Tools.DragPoint(TChart1.Chart)
        AddHandler dragpoint.Drag, AddressOf dragpoint_Drag
    End Sub

    Private Sub dragpoint_Drag(ByVal sender As Steema.TeeChart.Tools.DragPoint, ByVal index As Integer)
        Me.Text = "XValues:" & DateTime.FromOADate(series1.XValues(index)).ToShortDateString() & ",YValues: " & series1.YValues(index).ToString()

    End Sub
Can you tell us if previous code works as you expected?

I hope will helps.

Thanks,