Page 1 of 1

Move the scroll bar connected to the chart

Posted: Thu Feb 10, 2005 3:14 pm
by 8123657
Hello,
I have a scroll bar which moves the chart and each time I present the data on it I want the scrollbar to be on the beggining of the chart(hscrollbar).How do I do it?
Thank you!

Posted: Tue Mar 01, 2005 5:16 pm
by Pep
Hi,

you can use similar code to the following :

Code: Select all

		int AxisMax = 0;
		int AxisMin = 100;

		private void Form1_Load(object sender, System.EventArgs e)
		{
			Random Rnd = new Random();
			hScrollBar1.Minimum = 0;
			hScrollBar1.Maximum = 100;
			hScrollBar1.Value = 50;
			tChart1.Aspect.View3D = false;
			tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
		    for (int i=0;i<=100;i++)
				tChart1.Series[0].Add(i, Rnd.Next(100), "");
		}

		private void hScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
		{
		    if (hScrollBar1.Value < 50)
				tChart1.Axes.Bottom.SetMinMax(AxisMin - (50 - hScrollBar1.Value), AxisMax - (50 - hScrollBar1.Value));
			else
				tChart1.Axes.Bottom.SetMinMax(AxisMin + (hScrollBar1.Value - 50), AxisMax + (hScrollBar1.Value - 50));			
		}

		private void tChart1_Scroll(object sender, System.EventArgs e)
		{
			    if (((tChart1.Axes.Bottom.Minimum + 50) > hScrollBar1.Minimum) && ((tChart1.Axes.Bottom.Maximum - 50) < hScrollBar1.Maximum))
					hScrollBar1.Value = (int)tChart1.Axes.Bottom.Minimum + 50;
		}
	}