R
Ralf Abramowitsch
Hi,
I've got a flickering-problem when I try to add controls to a panel
(with flow layout) at runtime.
My code executes the following steps:
public void BuildView()
{
...
// suspend layout to not perform layout each time an item is added
mFlowLayoutPanel.SuspendLayout();
// remove all elements from the panel:
mFlowLayoutPanel.Controls.Clear();
// in a loop I add new items to the panel:
foreach (... in ...)
{
Panel panel = new Panel();
// set size of the panel:
panel.Size = MaxSize; // MaxSize is a constant value
// then the color of the panel is set
panel.BackColor = Color.CornflowerBlue;
// after all the panel is added the the panel with the flow
layout
mFlowLayoutPanel.Controls.Add(panel);
}
mFlowLayoutPanel.ResumeLayout(true);
}
Every time the method BuildView() is called, the panels are
flickering.
What went wrong? I thought that SuspendLayout() and ResumeLayout()
will avoid that? How can I avoid flickering every time my panels are
added to the flow layout panel?
Thanks a lot for your answer in advance.
Best regards,
Ralf
I've got a flickering-problem when I try to add controls to a panel
(with flow layout) at runtime.
My code executes the following steps:
public void BuildView()
{
...
// suspend layout to not perform layout each time an item is added
mFlowLayoutPanel.SuspendLayout();
// remove all elements from the panel:
mFlowLayoutPanel.Controls.Clear();
// in a loop I add new items to the panel:
foreach (... in ...)
{
Panel panel = new Panel();
// set size of the panel:
panel.Size = MaxSize; // MaxSize is a constant value
// then the color of the panel is set
panel.BackColor = Color.CornflowerBlue;
// after all the panel is added the the panel with the flow
layout
mFlowLayoutPanel.Controls.Add(panel);
}
mFlowLayoutPanel.ResumeLayout(true);
}
Every time the method BuildView() is called, the panels are
flickering.
What went wrong? I thought that SuspendLayout() and ResumeLayout()
will avoid that? How can I avoid flickering every time my panels are
added to the flow layout panel?
Thanks a lot for your answer in advance.
Best regards,
Ralf