当数据库中数据过多时,往往无法在一页中展示,所以非常需要一个滚动条来调节页面内容,那么C#中chart控件如何实现滚动条?
还是以软件【银行业会计技能训练系统】为例,如下图,X轴内容较多,如何实现如下效果的滚动条?
方法及源码如下:
本文基于文章【C#中chart控件如何连接并展示access数据库中特定内容】,在此基础上增加了滚动条功能。只需添加如下代码,即可实现X轴上的滚动条。
chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
chart1.ChartAreas["ChartArea1"].Area3DStyle.LightStyle = LightStyle.Realistic;
chart1.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(165)), ((System.Byte)(191)), ((System.Byte)(228)));
chart1.ChartAreas["ChartArea1"].CursorX.AutoScroll = true;
chart1.ChartAreas["ChartArea1"].AxisX.ScrollBar.Enabled = true;
chart1.ChartAreas["ChartArea1"].CursorX.IsUserEnabled = true;
chart1.ChartAreas["ChartArea1"].CursorX.IsUserSelectionEnabled = true;
chart1.