Private Sub DrawChart()
'this is only part of the chart drawing setup
With Chart1.ChartAreas(0)
.AxisX.Maximum = ChartAxisXMax + ZoomFactor
.AxisX.Minimum = ChartAxisXMin + ZoomFactor
.AxisY.Minimum = ChartAxisXMax + ZoomFactor
.AxisY.Maximum = ChartAxisXMax + ZoomFactor
End With
End Sub
Private Sub Chart1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Chart1.MouseWheel
ZoomFactor = e.Delta * SystemInformation.MouseWheelScrollLines / 100 ' WHEEL_DATA
DrawChart()
End Sub
我可能把它放在错误的地方吗?滚动鼠标后是否触发事件?轴最小值和最大值已经预设,所以它有什么问题?
答案 0 :(得分:0)
请使用此代码:
Private Sub Chart1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Chart1.MouseWheel
Dim ZoomFactor = e.Delta * SystemInformation.MouseWheelScrollLines / 100 ' WHEEL_DATA
With Chart1.ChartAreas(0)
.AxisX.Maximum = Chart1.ChartAreas(0).AxisX.Maximum - ZoomFactor
.AxisX.Minimum = Chart1.ChartAreas(0).AxisX.Minimum + ZoomFactor
.AxisY.Minimum = Chart1.ChartAreas(0).AxisY.Minimum + ZoomFactor
.AxisY.Maximum = Chart1.ChartAreas(0).AxisY.Maximum - ZoomFactor
End With
End Sub