|
こんなんでどうでしょう?
Private _mp As Point
Private Sub Chart1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseMove
_mp = e.Location
Chart1.Invalidate()
End Sub
Private Sub Chart1_PostPaint(sender As Object, e As System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs) Handles Chart1.PostPaint
Dim g = e.ChartGraphics.Graphics
'---> 既存の処理
'<--- 既存の処理
Dim axx = Chart1.ChartAreas(0).AxisX
Dim axy = Chart1.ChartAreas(0).AxisY
Dim x1 = axx.ValueToPixelPosition(axx.Minimum) 'グラフ領域右端のX座標
Dim y1 = axy.ValueToPixelPosition(axy.Maximum) 'グラフ領域上部のY座標
Dim x2 = axx.ValueToPixelPosition(axx.Maximum) 'グラフ領域左端のX座標
Dim y2 = axy.ValueToPixelPosition(axy.Minimum) 'グラフ領域下部のY座標
g.DrawLine(Pens.Gold, _mp.X, CInt(y1), _mp.X, CInt(y2))
g.DrawLine(Pens.Gold, CInt(x1), _mp.Y, CInt(x2), _mp.Y)
End Sub
|