WinForm ListControl MouseWheel Envent
2020-12-13 05:55
标签:winform style blog color 使用 io for 问题 最近在使用Listbox开发程序的时候, 遇到MouseWheel event 异常。 设置如下: 1. DrawModel:ownerDrawVariable. 2. InternalHeight:False. 3. ScrollAswalysVisible:True. 4. Overwrite DrawItem. 5. Overwrite MeasureItem. 问题是:当items 很多(超过一屏)的时候,HScrollbar enable auto, 这是如果鼠标滚轮翻屏的时候,会有2次闪烁,第二次是:最后一条item从屏幕顶端一下来,像是滚屏一样。使用鼠标点击scrollbar往下拉,没有问题。 解决办法: 重写 ListBox OnMouseWheel Envent: WinForm ListControl MouseWheel Envent,搜素材,soscw.com WinForm ListControl MouseWheel Envent 标签:winform style blog color 使用 io for 问题 原文地址:http://www.cnblogs.com/Rufy_Lu/p/3889601.html 1 protected override void OnMouseWheel(MouseEventArgs e)
2 {
12 int numberOfTextLinesToMove = e.Delta * SystemInformation.MouseWheelScrollLines / 120;
13 int numberOfPixelsToMove = (int)(numberOfTextLinesToMove * this.Font.Size);
14 GraphicsPath mousePath = new GraphicsPath();
15 if (numberOfPixelsToMove != 0)
16 {
17 System.Drawing.Drawing2D.Matrix translateMatrix = new System.Drawing.Drawing2D.Matrix();
18 translateMatrix.Translate(0, numberOfPixelsToMove);
19 mousePath.Transform(translateMatrix);
20 }
21 this.Invalidate();
22 }
文章标题:WinForm ListControl MouseWheel Envent
文章链接:http://soscw.com/essay/31987.html