码迷,mamicode.com
首页 > Windows程序 > 详细

C#中给滚动条增加鼠标滚动轮控制事件

时间:2015-01-16 12:31:17      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:

当滚动条的父控件获得焦点时,可以使用鼠标的滚动轮来控制滚动条

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.richTextBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(richTextBox1_MouseWheel);
}

void richTextBox1_MouseWheel(object sender, MouseEventArgs e)
{
this.Location = new System.Drawing.Point(this.Location.X, this.Location.Y + e.Delta);
}
}

以上是上下卷动,要想左右卷动,可修改为以下代码:

new System.Drawing.Point(this.Location.X + e.Delta, this.Location.Y);

C#中给滚动条增加鼠标滚动轮控制事件

标签:

原文地址:http://www.cnblogs.com/tommy-huang/p/4228268.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!