zedgraph EnableWheelZoom, how to get axis values after zooming?

自古美人都是妖i 提交于 2019-12-11 22:08:55

问题


In my vb.net project, I use zedgraph to draw figures. I find that the following properties work well to zoom figure on the center of mouse.

    Friend WithEvents gcMain As ZedGraph.ZedGraphControl
    Me.gcMain.IsZoomOnMouseCenter = True
    Me.gcMain.IsEnableWheelZoom = True

I have two toolstrip text boxes to show the minimum and maximum values of x axis. When I change values in text boxes, the x axis changes. The following code shows an example of handling the textbox. However I do not know how to update values in text boxes when the figure is zoomed by using IsEnableWheelZoom property. In zedgraph, ZedGraphControl_MouseWheel is a protected event.

 Friend WithEvents tbxRangeStart As System.Windows.Forms.ToolStripTextBox
     Private Sub tbxRangeStart_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbxRangeStart.KeyDown
    Try
        If e.KeyCode = Keys.Enter Then
            ' Change x Axis here
        End If
    Catch
    End Try
End Sub

回答1:


Use the ZoomEvent:

chart.ZoomEvent += chart_ZoomEvent
...
private void chart_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
{
    textBoxMax.Text = chart.GraphPane.XAxis.Scale.Max.ToString();
    textBoxMin.Text = chart.GraphPane.XAxis.Scale.Min.ToString();
}



回答2:


In vb.net, use following code

Private Sub gcMain_ZoomEvent(ByVal sender As ZedGraphControl, ByVal oldState As ZoomState, ByVal newState As ZoomState) Handles gcMain.ZoomEvent

'update text box here    
End Sub


来源:https://stackoverflow.com/questions/8536325/zedgraph-enablewheelzoom-how-to-get-axis-values-after-zooming

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!