Geeks With Blogs
Devin Rader's Blog I write the code...

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();
}
Posted on Tuesday, February 7, 2006 8:01 AM | Back to top


Comments on this post: Using the Mouse Wheel to zoom in and out of the UltraChart

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Hello,
I recommend testing bth properties for being between 0 and one, otherwise youll get an <ClassName id="ref-11">System.ArgumentOutOfRangeException</ClassName>
<Message id="ref-12">The value of this property must be between 0,00 and 1,00.</Message>
if the user zooms in manually in one of the axis.
Have a nice weekend,
Caroline
Left by Caroline on Feb 10, 2006 8:04 AM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Excellent point...yes, you definitly should test both Scales.
Left by Devin on Feb 10, 2006 8:06 AM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Still another comment:
- if you test for the properties to be >= 0.02 and <= 0.98 you avoid also crashes if the user zoomed manually and differently on the axes.

- in composite charts, you have to set these properties to the Axis elements, like this for example: if(this.ultraChart1.Axis.X.ScrollScale.Visible == true)
{
if (e.Delta<0)
{
if (this.ultraChart1.Axis.X.ScrollScale.Scale <= 0.98)
{ this.ultraChart1.Axis.X.ScrollScale.Scale += .02;
}
this.ultraChart1.InvalidateLayers();
this.ultraChart1.Refresh();
return;
}
The Invalidate() and Refresh() are needed because otherwise the zooming will occur only if you leave the control right after to mouse-wheeling.
Greetings, have fun,
Caroline
Left by Caroline on Feb 13, 2006 4:52 AM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Hi Devin ,

Am using Infrgistics NetAdvantage_NET_20073_CLR20 version(Trail Version)
Am unable to find MouseWheel event
1.Do i need at refer for any other dll
2.Do i need to update with latest version

how to generate MouseWheel event please help me out from issue

Thanks in Advance
Left by Ravi Kumar on Apr 02, 2009 5:31 PM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Hey Ravi,

Try attaching to the event through code.
I couldn't see the event in the designtime editor myself but it should be available if you try in your code.
Left by Kristof on Apr 06, 2009 1:50 AM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Thanks a lot works great!
Left by js on Feb 17, 2010 4:18 PM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
As a famous designer shoes, Super Cheap Christian Louboutin Shoes no doubt, Louboutin Christianity is the highest exposure.Christian Louboutin Shoes boots As a famous designer shoes .
Left by Christian Louboutin 2010 on May 13, 2010 4:25 AM

# cheap timberland boots
Requesting Gravatar...
All things in their being are good for timberland boots sale something.Difficult circumstances serve as a textbook of timberland boots life for people.Failure is the mother of success. -- Thomas Paine.For man is man and master of his timberland 6 inch boots fate.The unexamined life is not worth living. None is of freedom or of mens 6 inch timberland boots life deserving unless he daily conquers it anew. -- Erasmus.Our destiny offers not the cheap timberland boots cup of despair, but the chalice of timberland boots uk opportunity. So let us seize it, not in fear, but in gladness. -- R.M. Nixon.Living without an discount timberland boots aim is like sailing without a timberland womens roll top compass. -- John Ruskin.What makes life dreary is the want of motive. -- George Eliot.Towering genius timberland shoes disdains a beaten path. It seeks regions hitherto unexplored. There is no such timberland womens premium boots thing as a great talent without great will - power.The good seaman is known in bad weather.Gods determine what you're going to womens timberland premium boots be. An aim in life is the only fortune worth finding. -- Robert Louis Stevenson.While there is timberland winter boots life there is hope.Try not to become a man of success but rather try to become a man of value. -- A. Einstein.You have to believe in womens timberland boot yourself. That's the secret of success. -- Charles Chaplin.Pursue your object, be it what it will, steadily and indefatigably.We must accept finite timberland shoes store disappointment, but we must never lose infinite hope. -- Mattin Luther King.Energy and persistence conquer all things. -- Benjamin Franklin.Nothing seek timberland hiking boots , nothing find.Cease to struggle and you cease to live. -- Thomas Carlyle. http://www.timberland4you.co.uk/ YQ7
Left by timberland shoes on Jan 06, 2011 9:07 PM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
namespace "MouseEventArgs" could not found ,are you missing assembly or reference?
Left by latesh on May 19, 2011 11:47 PM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
what is ultraChart1? please explore it ...
Left by tarun on Jun 25, 2011 2:38 AM

# re: Using the Mouse Wheel to zoom in and out of the UltraChart
Requesting Gravatar...
Is there a specific namespace that needs to be declared to allow for the MNouseWheel event? I currently have the MouseEnter event but not the MouseWheel event. I am using the following Infragistics namespaces: Infragistics.UltraChart.Shared.Styles, Infragistics.UltraChart.Resources.Appearance, Infragistics.UltraChart.Core.Layers, & Infragistics.Win.UltraWinGrid


Left by Ruben on Jun 28, 2011 1:38 PM

Your comment:
 (will show your gravatar)


Copyright © Devin Rader | Powered by: GeeksWithBlogs.net