c#TextBox添加鼠标按下、失去焦点、鼠标移动等事件及重写
作者:野牛程序员:2023-12-25 13:18:06C#阅读 2375
c#TextBox添加鼠标按下、失去焦点、鼠标移动等事件及重写
using System; using System.Windows.Forms; class CustomTextBox : TextBox { public CustomTextBox() { this.MouseDown += CustomTextBox_MouseDown; this.LostFocus += CustomTextBox_LostFocus; this.MouseMove += CustomTextBox_MouseMove; } private void CustomTextBox_MouseDown(object sender, MouseEventArgs e) { // 处理鼠标按下事件 // Your code here } private void CustomTextBox_LostFocus(object sender, EventArgs e) { // 处理失去焦点事件 // Your code here } private void CustomTextBox_MouseMove(object sender, MouseEventArgs e) { // 处理鼠标移动事件 // Your code here } // 如果需要重写其他方法,可以继续添加 }
野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892
- 上一篇:C# 两种常见的内存拷贝方式
- 下一篇:CPU和GPU的设计区别