Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building Controls at runtime
Message
From
05/08/2004 22:37:35
 
 
To
05/08/2004 21:51:54
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00931205
Message ID:
00931211
Views:
20
Hi, Mike,

Yes, it is. As a very basic example, here's what you would do to add a textbox at runtime...
System.Windows.Forms.TextBox oText = new System.Windows.Forms.TextBox();
this.Controls.Add(oText);
oText.Visible = true;
oText.Top = 5;
In that example, I'm just using the base text control. If you've subclassed your textbox, you'd want to specify your textbox class instead.

You can also add a series of controls by using this.Controls.AddRange()

Actually, if you look at the Winform Designer generated code, that should give you ideas as to how it's done, because the controls you drop onto the form at designtime are added at runtime using 'this.Controls.Add'.

Hope that helps...
Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform