However an old version of this program has a function that allow the user to box-select individual or a group of points on the chart. Those point got boxed will be highlighted as a different color. Here is the problem: now in the TChart world, the default box-select event is for zooming. I tried to write some code in the Tchart.Zoomed event. See below. The idea is to detect if the user press the Ctrl key, if no, then do the normal zooming, if yes, then undo the zoom and do the box-selection.
It doesn't work very well. Can anybody point out the problem, or give me some alternative solutions?
Thanks
Ji
Code: Select all
Private Sub TChart2_Zoomed(sender As Object, e As EventArgs) Handles TChart2.Zoomed
If My.Computer.Keyboard.CtrlKeyDown Then
Dim rec As New Rectangle(New System.Drawing.Point(TChart2.Zoom.x0, TChart2.Zoom.y0),
New System.Drawing.Size(TChart2.Zoom.x1 - TChart2.Zoom.x0, TChart2.Zoom.y1 - TChart2.Zoom.y0))
'If TChart2.Zoom.HistorySteps.Count > 0 Then TChart2.Zoom.HistorySteps.RemoveAt(TChart2.Zoom.HistorySteps.Count - 1)
TChart2.Zoom.Undo()
For i = 0 To TChart2.Series.Count - 1
If rec.Contains(TChart2.Series(i).ValuePointToScreenPoint(TChart2.Series(i).XValues(0), TChart2.Series(i).YValues(0))) Then
'Do the highlighting here
TChart2.Series(i).Color = Color.Red
End If
Next
End If
End Sub