Page 1 of 1

how to limit the scrolling of axes

Posted: Wed Nov 12, 2008 1:55 pm
by 13045482
is there a way to limit the scrolling of axes. Currently if user right click on x axis and drag mose he can keep on scrolling the axis whether there is data or not. I want to restrict that. Only if data is there then user should be able to scroll.

Posted: Wed Nov 12, 2008 2:15 pm
by narcis
Hi shikha,

Yes, you can do something like in the code snippet below but using Scroll event and for min. and max. values.

Code: Select all

            void tChart1_UndoneZoom(object sender, EventArgs e)
            {
                  tChart1.Axes.Bottom.Automatic = true;
            }

            void tChart1_Zoomed(object sender, EventArgs e)
            {
                  if (tChart1.Axes.Bottom.Minimum < 0)
                  {
                        tChart1.Axes.Bottom.AutomaticMinimum = false;
                        tChart1.Axes.Bottom.Minimum = 0;
                        tChart1.Axes.Bottom.AutomaticMaximum = false;
                        tChart1.Axes.Bottom.Maximum = line1.MaxXValue();
                  }
            }
Hope this helps!