locked
tablelayoutpanel flicker / performance RRS feed

  • Question

  • We are finding that the tablelayoutpanel control is causing a lot of flicker, especially flicker when resizing.

    We have an windows forms architecture based on user controls and tablelayoutpanels (we use the CAB). Our major flicker issues happen on our detail UI elements, such as a single row data maintenance user control of the pattern:

    Page Title

    Label A: TextBoxA
    Label B: TextBoxB

    Save Button / Cancel Button

    These control are organised in a tablelayoutpanel with 2 columns (one for the labels and one for the textboxes) and the desired amount of rows (one for the Page Title, a spacer row, one for row A, one for row B, a spacer row, a row for Save and Cancel buttons). The 1st column is AutoSize and the 2nd column is set to a Size Type of 100% forcing it to take up the real estate on the form and the controls in it are set to Fill. This gives a nice usable UI layout / presentation in whatever the client screen size.

    Unfortunately, as I said above, we get seriously back flicker. When the form is rendered initially it is resized to the client screen size, causing flicker. Every time they tab it gets some flicker. If they resize the application it gets really very bad flicker, enough to make the 3.2GHz with good graphics card to stop and render like mad in a very non-quality appearance.

    We have tried

    SetStyle(ControlStyles.UserPaint, true);
    SetStyle(ControlStyles.AllPaintingInWmPaint, true);
    SetStyle(ControlStyles.DoubleBuffer, true);

    with no effect. I've looked all over google and these forums and can't find any answers or even people having the same issue!?!

    Is any body else experiencing this or have any suggestions...? (worse case scenario and rebuilding the application to use docking and panels instead of tablelayoutpanel and loose gazillions in time)

    Thanks in advance,

    Paul.

    Wednesday, June 14, 2006 4:51 AM

All replies

  • Shame that nobody has anything to say on this, especially if someone has any contraindicators or experience...
    Wednesday, June 28, 2006 4:07 AM
  • I am having the same problems.  I am thinking that I am going to have to resort to panels as well.  Did you find a solution?
    Thursday, July 20, 2006 3:50 PM
  • I tried panels and basically got the same problem. So, I'm not sure. We are just living with the poor UI performance for now.
    Wednesday, July 26, 2006 4:04 AM
  • Im having the same problem, i have tones of controls on each row. of the table layout panel .. and damn ... it flickers like hell.

    everytime it gets painted ... it redraw and flickers ...

    someone has a solution ?
    Friday, August 18, 2006 5:44 PM
  • The flicker is unbearable on my app too.

    Bumping this in hope of a response.

    Tuesday, August 29, 2006 4:30 AM
  • I found that one thing that exacerbated our problem was a stretched graphic background. Changing to a single colour removed the flicker on the simplest screens. Whereas something like a data entry screen with labels and data input fields in two columns still flickers terrribly on layout.
    Monday, September 25, 2006 9:51 PM
  •  

    I'm afraid there is no good solution to resolve TableLayoutPanel flickering issue. Doublebuffer = true will be a little bit helpful but if there are a lot of controls put on TableLayoutPanel, flickering will be always there.

    My suggestion is not to refresh all if there is only one control be updated. Anyway, redesign your application is MUST.

    Thursday, September 28, 2006 9:25 AM
  • Have you tried to set tablelayoutPanel visible property to False at the beginning and the back to True at the end?
    Tuesday, July 24, 2007 3:53 PM
  • Yes. One of the first things to try.

    Monday, July 30, 2007 5:31 AM
  • Same problem.  Even worse problem is performance - it can take a minute or more to build a table dynamically.  TLP is basically useless to me.  I just calculate my positions and set the control locations, pita.

     

    These helped me some:

     

    me.SuspendLayout

    'create table

    me.ResumeLayout(False)

    me.PerformLayout

     

    Bill

    Tuesday, December 11, 2007 2:30 PM

  • I have found a way to remove flickering. Here is what I did :

    Code Block

    public class MyTableLayout:TableLayoutPanel
        {
            public MyTableLayout()
            {
                this.DoubleBuffered = true;
            }
        }


    And it worked for me, I really had to have my own tablelayout to set the doublebuffered.

    I tried setting it on the Form.. didn't work

    So I tried this and it worked.

    Hope it helps!
    • Proposed as answer by WorkaholicDude Tuesday, February 24, 2009 8:57 PM
    Wednesday, December 12, 2007 7:34 PM
  • I know this is a bit late ....

     

    But I would just like to add that this solution worked very, very well for me. Flickering was reduced to near nothing.

     

    My table layout is contained within a custom control. Setting doublebuffered = true on both of these has eliminated the flicker entirely.

     

     

    Tuesday, April 15, 2008 5:54 AM
  • I had this problem and tried to suspend and resume layout and it still didn't work.    I had only labels in the tablelayout grid. 

    I kept the suspend/resume in place and then started playing around with the alignment of the labels in the grid.  I changed the alignment of all the labels to Left, Center, and the flickering magically stopped. 

    I guess the point is sometimes suspend/resume is not enough, and you should play around with the properties of objects that are in the cells of the tablelayoutpanel itself.

    oh... I also tried doublebuffered and it didn't work for me. 

    Good luck, this can be confusing...

    Dan


    Monday, July 14, 2008 7:37 PM
  • Nice.

     

    I applied the same concept to a standard panel, with the same result.

     

    Thanks very much.

    Thursday, October 30, 2008 2:10 PM
  • I found a combination of the setting DoubleBuffer = true helped on the form resizing flickering.

     

    (C++/CLR code)

    ref class MyTableLayoutPanel : public TableLayoutPanel

    {

    public:

    MyTableLayoutPanel()

    {

    DoubleBuffered = true;

    }

    };

     

    Also, to prevent flickering during a redraw operation - like deleting a row in the table, I do a SuspendLayout on the both the layout panel and the form before doing changes to the items.

     

    myTableLayout->Parent->SuspendLayout();

    myTableLayout->SuspendLayout();

     

    // Do your stuff here

    myTableLayout->Parent->ResumeLayout();

    myTableLayout->ResumeLayout();

     

     

    Monday, December 1, 2008 11:15 AM
  • I have had similar problem . i tried the solution mentioned by GoDaddy and it worked.


    Thanks

    Tuesday, February 24, 2009 8:58 PM
  • This is second time i am having this problem . Earlier when i had this problem , the screen was simple with just one table layout panel flickering and tried double buffered on that which solved the problem.

    But now i am working on a screen with nested table layout panels and lots of controls(labels , text boxes, buttons, radio buttons,... more than 100 controls).
    I am making a windows form with all these controls and it flickers a lot. Tried all of solutions mentioned in different threads - double buffered,CreateParams.
    This combination of double buffered and CreateParams only reduced the flickers to some extent. But didnt remove it totally . Now i can still see the flickers whenever i scroll up/down the screen. Also this work around increased CPU load to almost 100%. Thats awful.

    I couldnt believe Microsoft never released a fix for this. Thats shameful.  I am using .net 2.0 and windows xp. Did microsoft improve this in .net 3.0 or any other new versions?



    Thursday, April 23, 2009 7:16 PM
  • Go GoDaddy! That worked a treat, well done! Simply cannot understand why MS didn't make DoubleBuffered a public property of Panel, from which all this nonsense arises.

    Thursday, May 26, 2011 4:28 PM
  • Hi

    Here is the links to some cool stuff to make your controls filcker free.

    http://oops4you.blogspot.com/2011/05/flicker-free-controls-splitcontainer.html

    http://oops4you.blogspot.com/2011/05/flicker-free-controls-panel.html

    -Amit


    Amit Bansal http://www.oops4you.blogspot.com/
    Monday, May 30, 2011 9:44 AM
  • Works perfect even with gradient background panel. :) Thanks alot
    Monday, July 18, 2011 2:47 AM
  • I have found that creating a new TableLayoutPanel Class which enables setting of Double Buffering solved this issue for me.  Create the Class then change all instances of TableLayoutPanel creation in your code to TableLayoutPanelPlus

    VB.NET example follows

    Rob

    Imports System.ComponentModel
    Imports System.Windows.Forms


    Public Class TableLayoutPanelPlus
        Inherits TableLayoutPanel

        ' Double Buffered layout panel - removes flicker during resize operations.


        Public Sub New()

            MyBase.New()

            Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or
                  ControlStyles.UserPaint, True)
        End Sub

    End Class

    Tuesday, October 6, 2015 10:04 PM
  • I have found that creating a new TableLayoutPanel Class which enables setting of Double Buffering solved this issue for me.  Create the Class then change all instances of TableLayoutPanel creation in your code to TableLayoutPanelPlus

    VB.NET example follows

    Rob

    Imports System.ComponentModel
    Imports System.Windows.Forms


    Public Class TableLayoutPanelPlus
        Inherits TableLayoutPanel

        ' Double Buffered layout panel - removes flicker during resize operations.


        Public Sub New()

            MyBase.New()

            Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or
                  ControlStyles.UserPaint, True)
        End Sub

    End Class

    This problem was killing me.

    Your solution worked like a charm. Thanks a lot!


    Sunday, December 6, 2015 2:19 PM
  • Hello "One of the Old Hands",

    I'm having the same problem with my tablelayoutpanels and so I was very interested to read your code.

    My problem is that I'm still a beginner and I have a couple of questions:

    1. Where exactly do I paste your code and how will the new "TableLayoutPanelPlus" appear in my toolbox?

    2. If possible, I do not want to do my whole layout again, how can I replace the old tablelayoutpanel in my program?

    3. I also have group boxes in my program. Is it necessary to write a new class for them as well to avoid flickering? Following your example of the tablelayoutpanel?

    Thanks a lot in advance for any tipps to help me.

    Munti12

    Monday, March 14, 2016 8:59 AM