求助!!!我的程序是关于串口通信收集陀螺仪的数据的,其中将采集到的数据通过Chart来绘图。但是用ScrollBar的滚动条时,一按想拉回去看原来画的图滚动条就会消失,这是什么问题
for (int num = 0; num < 3; num++)
{
this.chart1.ChartAreas[num].AxisX.Minimum = 0;
this.chart1.ChartAreas[num].AxisX.Maximum = w;
this.chart1.ChartAreas[num].AxisX.ScrollBar.Enabled = true;
this.chart1.ChartAreas[num].AxisX.ScrollBar.IsPositionedInside = true;
this.chart1.ChartAreas[num].AxisX.ScaleView.Size = w;
this.chart1.ChartAreas[num].AxisX.IsStartedFromZero = true;
this.chart1.ChartAreas[num].AxisX.Interval = w / 10;
this.chart1.ChartAreas[num].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;
this.chart1.ChartAreas[num].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;
干掉scollbar这种垃圾东西,手动写拖拽代码
ch_a=chart1.ChartAreas[0];
ch_a.AxisX.ScrollBar.Enabled = false;
ch_a.AxisX.ScrollBar.Size = 20;
ch_a.AxisX.ScaleView.Size = xywidth()[0];
ch_a.AxisX.ScaleView.MinSize = 1;
ch_a.AxisY.LabelStyle.Angle = 90;//轴显示角度
把chart放在panel里面,然后鼠标控制左右滑动
//给garph拖拽
public int dfg = 0;
public void grap_move(Panel grap)
{
Chart ch = (Chart)grap.Controls["ct1"];
ch.MouseDown += (object sen, MouseEventArgs ef) =>
{
dfg = ef.X;
grap.Cursor = Cursors.Hand;
};
ch.MouseUp += (object sen, MouseEventArgs ef) =>
{
if (ef.Button == MouseButtons.Left)
{
if (ch.Series[0].Points.Count > xywidth()[0])
{
ch.ChartAreas[0].AxisX.ScaleView.Position -= Convert.ToInt32((ef.X - dfg) / 8) + 1;
dfg = 0;
}
}
grap.Cursor = Cursors.Default;
};
}