control flickering when resizing RRS feed

  • Question

  • Hi,
    I am developing a program which is a typical client application, which contains menu bar, tool bar, status bar, splitter container, listbox, buttons, panels etc. During the layout design, i have implemented docking or anchorring to all the controls. But how can i eliminate the flickering problem (especially to the bottons, listbox etc) when i resize the form?
    I follow the suggestions from the web, and put some "setstyle" setting during loading the form, something like:
    SetStyle(ControlStyles.UserPaint,true); // set all painting to be user drawn
    SetStyle(ControlStyles.Opaque,true); // dont draw background if you dont need to.

    but VB doesn't have those settings. so it doesn't help, how can i solve that?

    Tuesday, October 3, 2006 6:22 AM


All replies

  • Hi,

    Visual Basic does have does settings. SetStyle is a method of the System.Windows.Forms.Form class and contain bit values.

    One way to reduce flickering is to enable double buffering, which is supported by the .NET framework 2.0.

    Here's the VB syntax:

    Public Sub EnableDoubleBuffering()
       ' Set the value of the double-buffering style bits to true.
       Me.SetStyle(ControlStyles.DoubleBuffer _
         Or ControlStyles.UserPaint _
         Or ControlStyles.AllPaintingInWmPaint, _
    End Sub

    You can find the documentation for the SetStyle method here and the documentation on how to use double buffering here

    Hope this helps,


    Tuesday, October 3, 2006 6:34 AM
  • Thanks for that, but seems it doesn't solve the flickering problem. It remains the same as before. I called the subroutine under Form1.New, after the InitializeComponent() subroutine. is this the place i should put the code?
    Tuesday, October 3, 2006 7:16 AM
  • To start with, set the DoubleBuffered property of the form to true.

    If this doesn't help, see the following documents for more info on doubled buffering



    Tuesday, October 3, 2006 7:27 AM
  • I built and run the executable file for the program, and the flickering problem for some reason reduce significantly, it doesn't look that bad as it is showed during design time. I still leave the double-buffering code in the program.

    Thanks for the help.
    Wednesday, October 4, 2006 4:10 AM
  • If your problem is solved, could you please mark the thread as 'answered' so others will know it's solved?


    Wednesday, October 4, 2006 6:33 AM