Table Layout Pan Flickering

rfazendeiro

Centurion
Joined
Mar 8, 2004
Messages
110
Hello to all,

I'm currently trying to add at runtime some rows to a Table Layout Panel. With the property RowCount i can add how many rows I need.

So for a test i put in a textbox and a botton and when the user clicks the button it creates the number of row indicated in the textbox and add somes controls to them.

My problem is the flickering that creating the rows in run time causes. How can i cause the flicking to desapear of at least lower it ?

here is a basic example to create the rows

C#:
        private void fillData()
        {

            //Clear all the controls   
            tlpWarranty.Controls.Clear();
            tlpWarranty.RowStyles.Clear();
            tlpWarranty.AutoSize = true;

            //Set the new count
            tlpWarranty.RowCount = Convert.ToInt16(textBox1.Text);

            for (int i = 0; i < tlpWarranty.RowCount; i++)
            {
                tlpWarranty.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100));
                Label lblLabel = new Label();

                lblLabel.Text = "Label control: " + i.ToString();

                lblLabel.Font = new Font("Verdana", 8, FontStyle.Bold | FontStyle.Regular);

                lblLabel.AutoSize = true;

                Label lblData = new Label();

                lblData.Text = "Data for entity (" + i.ToString() + ")";

                lblData.Font = new Font("Verdana", 8, FontStyle.Regular);

                lblData.AutoSize = true;

                tlpWarranty.Controls.Add(lblLabel, 0, i);

                tlpWarranty.Controls.Add(lblData, 1, i);
            }
        }
 
yea i tried that too and it works but i found that there r 2 methods that solve my problem

SuspendLayout and ResumeLayout

thx for the response
 
Back
Top