zedgraph EnableWheelZoom,缩放后如何获取轴值?

发布于 2024-12-21 08:56:35 字数 776 浏览 1 评论 0原文

在我的 vb.net 项目中,我使用 zedgraph 来绘制图形。我发现以下属性可以很好地缩放鼠标中心的图形。

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

我有两个工具条文本框来显示 x 轴的最小值和最大值。当我更改文本框中的值时,x 轴会发生变化。以下代码显示了处理文本框的示例。 但是,当使用 IsEnableWheelZoom 属性缩放图形时,我不知道如何更新文本框中的值。在 zedgraph 中,ZedGraphControl_MouseWheel 是受保护的事件。

 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-12-28 08:56:35

使用 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();
}

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();
}
挽清梦 2024-12-28 08:56:35

在vb.net中,使用以下代码

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文