是的,就是这样。微软没有给ListView加上Scroll事件。这已经作为一项意见提交给了微软,在dotNET v2.0里面有望加上Scroll事件。
不过现在我们怎么办?
我们现在只能自己动手,丰衣足食了。
例子代码:
class MyListView : ListView
{
public event EventHandler HScroll;
public event EventHandler VScroll;
MyListView()
{
this.HScroll += new EventHandler(OnHScroll);
this.VScroll += new EventHandler(OnVScroll);
}
const int WM_HSCROLL = 0x0114;
const int WM_VSCROLL = 0x0115;
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_HSCROLL)
{
OnHScroll(this, new EventArgs());
}
else if(m.Msg == WM_VSCROLL)
{
OnVScroll(this, new EventArgs());
}
base.WndProc (ref m);
}
virtual protected void OnHScroll(object sender, EventArgs e)
{
}
virtual protected void OnVScroll(object sender, EventArgs e)
{
}
}
本文地址:http://com.8s8s.com/it/it42173.htm