Demonstration of e.Delta Property of MouseWheel

Demonstration of e DELTA property of MouseWheel scroll UP/ down in visual

C# Control things with scroll of mouse wheels.

This is a simple demonstration of e.Delta property of MouseWheel event , On scroll Up and Down of Mouse wheel. (MouseEventHandler).

Mouse wheel event can be very handy and use full for some cool application for your projects , where you can do things with scroll of mouse. For example, In my project for LCD display using pic18f4550 using USB , I used the same concept of e.Delta property in C# for controlling text on a LCD display on mouse scroll up and down ( http://www.youtube.com/watch?v=xMIhc4DsJ3A ).

 

The sample below shows the logic behind the e.Delta property, Download a copy of a project at the bottom of this page for better understanding. A block of code below shows the simple logic behind it.

First you have to initialize the MouseWheel event

“this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseWheel);”

You can use it under a button where the scrolling event will work only after you click the button under which the above sample is defined or you can put it under Public form , InitializeComponent(); directly from the beginning.
     

private void Form1_MouseWheel(object sender, MouseEventArgs e)

{

if (e.Delta > 0) // On Scroll up mouse wheels.  

{

DO Something;                      

}           

else  //scrolling down mouse wheels       

{        

  DO something Else;

}

}

Namespace:  System.Windows.Forms

________________________________________________________

 

Download Sample copy of Visual C# project here.

Download project : e.Delta Mouse wheel event

Thanks for reading
 

Rakesh Mondal
ron

Tags: