平滑滚动.NET形式平滑、形式、NET

2023-09-06 09:30:33 作者:南栀倾寒°

我使用的形式在.NET中,我在运行时动态增加许多链接标签, 我加入这些linklabels到面板,并补充说,面板的WinForm的。当linklabels的没有增加的形式推出了自动滚动条(垂直)... 现在,当我向下滚动使用自动滚屏的形式不更新其观点,因为我滚动的形式被刷新只有当我停止滚动... 此外,当它刷新它看起来太糟糕了。我可以看到它是如何绘制慢慢....

Hi I am using forms in .net and i am adding lots of linked labels dynamically during runtime, I am adding these linklabels to panel and adding that panel to the winform. When the no of linklabels increases the form puts out an auto scrollbar(vertical)... Now when i scroll down using that autoscroll the form is not updating its view as i scroll, the form gets refreshed only when i stop scrolling... Also when it refresh it looks too bad.. i can see how it draws slowly....

有没有人处理这个?

我试过form.refresh()的滚动事件处理程序,但这似乎并没有帮助。

I tried form.refresh() in scroll event handler but that doesn't seem to help..

任何线索?

推荐答案

流行到这一类(用户控件,面板等),那么它将与拇指拖累。

Pop this into your class (UserControl, Panel, etc) , then it will work with thumb drag.

private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;

protected override void WndProc (ref Message m)
{
    if ((m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
    && (((int)m.WParam & 0xFFFF) == 5))
    {
        // Change SB_THUMBTRACK to SB_THUMBPOSITION
        m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
    }
base.WndProc (ref m);
}