C#中给滚动条增加鼠标滚动轮控制事件
当滚动条的父控件获得焦点时,可以使用鼠标的滚动轮来控制滚动条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);文档来源:51CTO技术博客https://blog.51cto.com/u_15311900/3177415
页:
[1]