I want to hook a mouse wheel event to my scroll bar but i cannot see mouse开发者_StackOverflow中文版 wheel event in control properties. I have a form on which i have a panel and a vertical scroll bar. So far my scroll bar doesn't work with the mouse wheel. I need that event to hook it with my scroll bar. How to do it??
You need to attach to the MouseWheel event:
Occurs when the mouse wheel moves while the control has focus.
For example:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.MouseWheel += new MouseEventHandler(MouseWheelEvent);
this.MouseMove += new MouseEventHandler(MouseWheelEvent);
}
private void MouseWheelEvent(object sender, MouseEventArgs e)
{
Console.Out.WriteLine(e.Delta);
}
}
精彩评论