Reduce Flicker of .NET FlowLayoutPanel

3.4k Views Asked by At

I'm clearing and adding multiple LinkLabel's to FlowLayoutPanel, every couple of seconds. It works fine, but flicker is quite noticeable. Is there any way to reduce it? I tried to set Form.DoubleBuffering, it didn't help.

2

There are 2 best solutions below

3
SharpAffair On BEST ANSWER

Managed by creating a custom control derived from FlowLayoutPanel and setting its styles as shown below:

Public Class CustomFlowLayoutPanel Inherits FlowLayoutPanel

Public Sub New()
    MyBase.New()

    SetStyle(ControlStyles.UserPaint, True)
    SetStyle(ControlStyles.AllPaintingInWmPaint, True)
    SetStyle(ControlStyles.DoubleBuffer, True)

End Sub

End Class

0
Shekhar_Pro On

Try calling SuspendLayout() for the panel before adding controls to it and then call ResumeLayout() on the Panel. You may lose that flicker a bit.