问题
I have main Panel and Auto Scroll=true, and all controls are placed on main panel. Functionality works fine but when I click on any control or scroll down or up so it start flickering for a second each time I click or Scroll,
I also set
DoubleBuffered = true;
but it is not working for me.
could any body please suggest me solution or new code which can help me I alrasy spent 2 days on this problem. thanks in advance.
回答1:
You can try to put this into your forms class:
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);
}
You could also add this to your forms class constructor:
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
Im using windows 8, and i dont get flicker from a panel with AutoScroll=true. but the above methods should solve the flicker.
来源:https://stackoverflow.com/questions/16009743/how-to-stop-flickering-in-c-sharp-windowsforms-form-application