C#为什么有些控件无法绑定事件?
比如我声明了个vscrollEvent,但却无法绑定到TreeView上。是哪里出错了?另外如何给TreeView绑定scroll事件?...
比如我声明了个 vscrollEvent,但却无法绑定到TreeView上。是哪里出错了?另外如何给TreeView绑定scroll事件?
展开
展开全部
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.myTreeView1.VScrollEvent += delegate
{
this.Text = "纵向滚动了!";
};
}
private void button1_Click(object sender, EventArgs e)
{
this.Text = "";//清空便于对比
}
}
public class MyTreeView : TreeView
{
public event EventHandler HScrollEvent;
public event EventHandler VScrollEvent;
protected override void WndProc(ref Message m)
{
Debug.Print(m.Msg.ToString());
switch (m.Msg.ToString())
{
case "277":
if (this.VScrollEvent != null)
this.VScrollEvent(this, null);
break;
case "你自己检测数字":
if (this.HScrollEvent != null)
this.HScrollEvent(this, null);
break;
default:
break;
}
base.WndProc(ref m);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询