# [.net] [C# , Compact Framework 1.1] Component creation / updating visual problem.

## Recommended Posts

Hi! I have a standard form, however some (lots of) buttons are created using code inside the constructor. During the creation of these buttons the form is updated, resulting in it being visible (even though it's pretty fast) that each control is added to the form (row by row, each for from left to right). Is there any way to avoid this? ::::: EXAMPLE CODE BEGIN
public FormClassName()
{
// This is the constructor of "public class FromClassName : System.Windows.Forms.Form"

//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

// BEGIN: I would like everything inside the for-loops to turn up "at once"
for (int j = 0 ; j < 8 ; j++)
for (int i = 0 ; i < 8 ; i++)
{
Button b = new System.Windows.Forms.Button();
b.Parent = this;
b.Bounds = new Rectangle(0,0,20,20);
b.Location = new System.Drawing.Point(i * b.Width, j * b.Height);
}
//   END: I would like everything inside the for-loops to turn up "at once"
}

::::: EXAMPLE CODE END Is this possible? And if I am not making myself clear don't hesitate to tell me so. [Edited by - kentylarsson on November 29, 2005 8:20:51 PM]

##### Share on other sites
Neil Kerkin    164
Not sure if it will help but you might want to investigate the SuspendLayout and ResumeLayout functions ie

this.SuspendLayout();
this.ResumeLayout(false);

##### Share on other sites
LiyonDR    169
Probably not the smoothest method but you could create an array of Buttons or an ArrayList and then use Controls.AddRange to add it to the controls list after your done creating them all.

Liyon

##### Share on other sites
Thanks for you answer! Unfortunately I need to stick with Compact Framework 1.1, which makes those two methods unavailable. Otherwise it would have worked.

Anyone else who has any idea?

 LiyonDR: No it's not available using the CF 1.1 either. :(

[edit2]

I found out about Control.CopyTo() and used it instead without any improvement.

[Edited by - kentylarsson on November 30, 2005 1:57:56 AM]

##### Share on other sites
Guest Anonymous Poster
public FormClassName()
{
// This is the constructor of "public class FromClassName : System.Windows.Forms.Form"

//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

// BEGIN: I would like everything inside the for-loops to turn up "at once"
for (int j = 0 ; j <

##### Share on other sites
Guest Anonymous Poster
sorry about that previous post - not sure what happened there.

try setting b.Visible = false before this.Controls.Add(b)

then add this code at the end:

foreach( Control ctl in this.Controls )
{
ctl.Visible = true;
}

this way all controls are added to the form invisible then shown together at the end, hope this helps.

##### Share on other sites
Toolmaker    967
Quote:
 Original post by kentylarssonThanks for you answer! Unfortunately I need to stick with Compact Framework 1.1, which makes those two methods unavailable. Otherwise it would have worked.Anyone else who has any idea? LiyonDR: No it's not available using the CF 1.1 either. :([edit2]I found out about Control.CopyTo() and used it instead without any improvement.

Perhaps you should learn to RTFM, because SuspendLayout and ResumeLayout are part of the .NET framework 1.1. I've seen it many times in the Auto generated code, and I check the MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclasssuspendlayouttopic.asp

That link, will indeed tell you that SuspendLayout/ResumeLayout are part of the .NET 1.1 framework.

Toolmaker

##### Share on other sites
Quote:
Original post by Toolmaker
Quote:
 Original post by kentylarssonThanks for you answer! Unfortunately I need to stick with Compact Framework 1.1, which makes those two methods unavailable. Otherwise it would have worked.Anyone else who has any idea? LiyonDR: No it's not available using the CF 1.1 either. :([edit2]I found out about Control.CopyTo() and used it instead without any improvement.

Perhaps you should learn to RTFM, because SuspendLayout and ResumeLayout are part of the .NET framework 1.1. I've seen it many times in the Auto generated code, and I check the MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclasssuspendlayouttopic.asp

That link, will indeed tell you that SuspendLayout/ResumeLayout are part of the .NET 1.1 framework.

Toolmaker

Thanks for your hilarious answer Toolmaker! You managed to be both unhelpful, unfriendly and most of all incompetent. And all at the same time!

If you tell someone else to RTFM you should at least be able to read it yourself, and be able to correctly read the topic you're replying to.

1. The question was about .NET Compact Framework 1.1, it even said so in your quote of my post.
2. SuspendLayout and ResumeLayout are not part of .NET Compact Framework 1.1. The methods which are availible in CF 1.1 are marked so under the method name in the list. Look in MSDN for confirmation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsControlMethodsTopic.asp

Anonymous Poster
I'll try your suggestion later today, I hope that it will solve my problem but I am doubtful. Thanks for you answer!