Hey
I need to redefine when to pan and zoom in a chart on a WinForm. Actually what I want is to use the zoom tool like normal (left click), but when the user press Ctrl while left clicking I want to pan the chart instead - and use the right click as a normal popup menu. I have solved the problem with disabling pan-funtionality on right click but how do I solve the "Ctrl+Left key" problem?
/Claus
Controlling zoom/pan with the control key
Re: Controlling zoom/pan with the control key
Hello Claus,
I suggest you use MouseDown and ModifierKeys method to achieve as you want Ctrl MouseLeft as do in next lines of code:
Can you tell us if previous code works as you want? If you have any problems please, let me know.
Thanks,
I suggest you use MouseDown and ModifierKeys method to achieve as you want Ctrl MouseLeft as do in next lines of code:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar1 = new Bar(tChart1.Chart);
bar1.FillSampleValues();
bar1.SideMargins = false;
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
if (ModifierKeys == Keys.Control && e.Button == MouseButtons.Left)
{
tChart1.Zoom.Allow = false;
tChart1.Panning.MouseButton = MouseButtons.Left;
}
else
{
tChart1.Zoom.Allow = true;
tChart1.Panning.MouseButton = MouseButtons.Right;
}
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Controlling zoom/pan with the control key
Hey
It did not work with MouseDown - but it works perfectly in a KeyUp/KeyDown combination - I was just missing the "tChart1.Panning.MouseButton" property, so now I have a working solution - thanks!
/Claus
It did not work with MouseDown - but it works perfectly in a KeyUp/KeyDown combination - I was just missing the "tChart1.Panning.MouseButton" property, so now I have a working solution - thanks!
/Claus
Re: Controlling zoom/pan with the control key
Hello Claus,
I am glad that your can solve your problem.
Thanks for your information,
I am glad that your can solve your problem.
Thanks for your information,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |