Page 1 of 1

MouseWheel

Posted: Fri Feb 02, 2007 1:26 pm
by 9642161
I would like to use the mousewheel to move a vertical cursor across the screen. I set the cursor on the mouse down and am able to detect the mouse wheel. What would be the best approach to achieve this

Thanks

Posted: Fri Feb 02, 2007 3:59 pm
by narcis
Hi histry,

You can use TeeChart's MouseWheel event like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			line1.FillSampleValues();
			cursorTool1.YValue = line1.MinYValue() + ((line1.MaxYValue() - line1.MinYValue()) / 2);

			tChart1.MouseWheel += new MouseEventHandler(tChart1_MouseWheel);
		}

		void tChart1_MouseWheel(object sender, MouseEventArgs e)
		{
			cursorTool1.YValue += e.Delta/10;
		}

Posted: Fri Feb 02, 2007 4:06 pm
by 9642161
Thanks that helps. If I have multipe cursors on the screen is the way of determining which cursor the mouse is over as I want to be able to select a cursor and move the selected cursor

Posted: Fri Feb 02, 2007 4:39 pm
by narcis
Hi histry,

Then you can do something like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			line1.FillSampleValues();
			cursorTool1.YValue = line1.MinYValue() + ((line1.MaxYValue() - line1.MinYValue()) / 2);
			cursorTool2.YValue = line1.MinYValue() + ((cursorTool1.YValue - line1.MinYValue()) / 2);

			tChart1.MouseWheel += new MouseEventHandler(tChart1_MouseWheel);
		}

		void tChart1_MouseWheel(object sender, MouseEventArgs e)
		{
			foreach (Steema.TeeChart.Tools.Tool  t in tChart1.Tools)
			{
				if (t is Steema.TeeChart.Tools.CursorTool)
				{
					Steema.TeeChart.Tools.CursorTool c = (Steema.TeeChart.Tools.CursorTool)t;
			
					if (c.Clicked(e.X, e.Y) == Steema.TeeChart.Tools.CursorClicked.Horizontal)
					{
						c.YValue += e.Delta / 10;
					}
				}
			}
		}