Move the scroll bar connected to the chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
.net
Newbie
Newbie
Posts: 10
Joined: Thu Jan 29, 2004 5:00 am
Location: IL

Move the scroll bar connected to the chart

Post by .net » Thu Feb 10, 2005 3:14 pm

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!

Pep
Site Admin
Site Admin
Posts: 3181
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Mar 01, 2005 5:16 pm

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;
		}
	}

Post Reply