Tuesday, February 07, 2006 8:01 AM
Heres a small code snippet that demonstrates how to use the MouseWheel event to change the scale of the UltraChart. As the user scrolls forward or backward, the chart zooms in or out. Also notice that in order for the chart control to capture the MouseWheel event it has to have Focus, so you can just use the MouseEnter event to give the chart control focus as soon as the mouse enters the control.
private void ultraChart1_MouseWheel(object sender, MouseEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Delta);
if (e.Delta<0)
{
if (this.ultraChart1.Axis.X.ScrollScale.Scale<1)
{
this.ultraChart1.Axis.X.ScrollScale.Scale+=.02;
this.ultraChart1.Axis.Y.ScrollScale.Scale+=.02;
}
return;
}
if(e.Delta>0)
{
if (this.ultraChart1.Axis.X.ScrollScale.Scale>0)
{
this.ultraChart1.Axis.X.ScrollScale.Scale-=.02;
this.ultraChart1.Axis.Y.ScrollScale.Scale-=.02;
}
return;
}
}
private void ultraChart1_MouseEnter(object sender, System.EventArgs e)
{
this.ultraChart1.Focus();
}