all groups > dotnet windows forms > june 2005 >
You're in the

dotnet windows forms

group:

Manually adding usercontrol to panel on form


Manually adding usercontrol to panel on form tonny.steen NO[at]SPAM invenia.no
6/29/2005 1:02:30 AM
dotnet windows forms:
I wonder if there is a way to have a flicker free initial paint of a
usercontrol on a panel (on a form) when done manually. My usercontrol
with many controls is first painted in its origional size, then resized
to fit the host panel (docked). This is not nice to look at since the
initial load/paint of the usercontrol is slow. So, my question is:

Is there a way to first have it resized then painted?

Code snipet from form (start):
private UserControl currentUserControl;

private void button1_Click(object sender, System.EventArgs e)
{
if (this.currentUserControl != null)
{
this.panel1.Controls.Remove(currentUserControl);
this.currentUserControl = null;
}
this.currentUserControl = new UserControl1();
this.currentUserControl.Name = "currentUserControl";
this.panel1.Controls.Add(currentUserControl);
this.panel1.Controls[0].Dock = DockStyle.Fill;
this.currentUserControl.Visible = true;
}
Code snipet (end):

- Tonny
Re: Manually adding usercontrol to panel on form Jim Hughes
6/29/2005 7:09:03 AM
[quoted text, click to view]

Perhaps it might work better if you wrap it in SuspendLayout / ResumeLayout
calls

AddThis Social Bookmark Button