rfazendeiro Posted September 12, 2008 Posted September 12, 2008 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 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); } } Quote
davearia Posted September 25, 2008 Posted September 25, 2008 I tend to set the panel to be not visible when I am updating it contents if the flickering occurs. Quote
rfazendeiro Posted September 26, 2008 Author Posted September 26, 2008 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.