C# 在 Microsoft Chart Control for Windows Forms 上启用滚动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1212914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable Scrolling on the Microsoft Chart Control for Windows Forms
提问by Sebas
I understand that
我明白那个
Scrollbars are only shown when zooming occurs. In other words, even if a scrollbar is enabled, it will only be visible when a view is being displayed.
滚动条仅在发生缩放时显示。换句话说,即使启用了滚动条,它也只会在显示视图时可见。
but then, how do I enable zooming on the Chart Control. I am looking to do this in order to avoid having my Axis-Lables break into two columns after a certain number of values are added to the graph.
但是,如何在图表控件上启用缩放。我希望这样做是为了避免在将一定数量的值添加到图形后我的 Axis-Lables 分成两列。
回答by Sebas
ok, this explains it: http://msdn.microsoft.com/en-us/library/dd456730.aspx
好的,这解释了:http: //msdn.microsoft.com/en-us/library/dd456730.aspx
In the Chart control for Windows Forms, you can give the chart viewer the flexibility to zoom and scroll the data view by enabling cursors and selections. To do this, use the CursorX and CursorY properties.
You can enable cursors, zooming, and scrolling for the X or Y axes, or both. To enable the cursor in the data view, set the IsUserEnabled property to True. To enable data view selection, use the IsUserSelectionEnabled property to True. Zooming and Scrolling
By default, zooming and scrolling are enabled when you enable data view selection. Use the ScaleView and ScrollBar properties in the chart area's X or Y axis to adjust the look and feel of the scroll bar when it is shown.
To disable zooming, use the Zoomable property found in the respective axis' ScaleView object. To disable scrolling, use the Enabled property found in the respective axis' ScrollBar object.
在 Windows 窗体的 Chart 控件中,您可以通过启用光标和选择使图表查看器灵活地缩放和滚动数据视图。为此,请使用 CursorX 和 CursorY 属性。
您可以为 X 轴或 Y 轴或两者启用光标、缩放和滚动。要在数据视图中启用光标,请将 IsUserEnabled 属性设置为 True。要启用数据视图选择,请将 IsUserSelectionEnabled 属性设置为 True。缩放和滚动
默认情况下,启用数据视图选择时会启用缩放和滚动。使用图表区域 X 或 Y 轴中的 ScaleView 和 ScrollBar 属性来调整滚动条显示时的外观和感觉。
要禁用缩放,请使用在相应轴的 ScaleView 对象中找到的 Zoomable 属性。要禁用滚动,请使用相应轴的 ScrollBar 对象中的 Enabled 属性。
回答by coding_is_fun
Maybe this will help.
也许这会有所帮助。
Click the chart in the design view.
单击设计视图中的图表。
Under properties choose: Chart Area (collections) it is the [...] button
在属性下选择:图表区域(集合)它是 [...] 按钮
That brings up a bunch the ChartArea Collections Editor.
这带来了一堆 ChartArea 集合编辑器。
Scroll down to the CursorX (x is the horizontal)and switch IsUserEnabled to TRUE and IsUserSelection to TRUE
向下滚动到 CursorX(x 是水平方向)并将 IsUserEnabled 切换为 TRUE 并将 IsUserSelection 切换为 TRUE
Then you can click and drag areas of the chart on the horizontal axis to 'zoom' in.
然后,您可以单击并拖动水平轴上的图表区域以“放大”。
There might be a more intuitive way to do all this but it worked.
可能有一种更直观的方法来完成这一切,但它奏效了。
Good luck.
祝你好运。