I have a tableLayoutPanel
that I use with a Windows Form. The control is populated from a datatable
which holds sql server data. I've already confirmed that the select
statement is not the issue.
The datatable is frequently updated, so the tableLayoutPanel
is also frequently updated. It's essentially working well, but it gets to a point that it becomes a little slower and that flickering is more noticeable.
Everytime I need to refresh the control, this code is executed:
public void FillTlp()
{
tableLayoutPanel1.Controls.Clear();
tableLayoutPanel1.ColumnStyles.Clear();
foreach (DataRow r in DT.Rows)
{
UcColor button = new UcColor(r);
tableLayoutPanel1.Controls.Add(button);//, colNumNew, rowNum);
}
this.Controls.Add(tableLayoutPanel1);
}
Since the will always have 8 rows, I execute the following code in the Form constructor only once, but I don't see much benefit:
public FormDoctorMonitor()
{
tableLayoutPanel1.RowStyles.Clear();
tableLayoutPanel1.RowCount = 8;
FillTlp();
}
How else can I optimize populating the tableLayoutPanel
?
Thanks.