Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2003, 11:32 AM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create dynamic controls

Hi

Is it possible to create dynamically controls such as checboxes, radiobuttons, textboxes, etc, in a Window form?

I need to create it, when I execute my application.

 
Old November 20th, 2003, 06:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, sure you can. In fact, that's what's happening with the code that the designer creates for you. You can do things like this:
Code:
Label myLabel = new Label();
myLabel.Name = "Label1";
myLabel.Text = "I am a new Label";
this.Controls.Add(myLabel);
myLabel.Location = new Point(100, 100);
This will create a new Label and add it to the form at the specified location with the specified text.


HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old November 21st, 2003, 12:36 PM
Authorized User
 
Join Date: Nov 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thaks, Imar






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic User Controls.... Jayahar ASP.NET 2.0 Professional 8 October 12th, 2007 01:27 AM
Delete Dynamic Controls rhd110 General .NET 1 July 22nd, 2007 04:23 AM
Dynamic .NET Controls. rupen ASP.NET 1.0 and 1.1 Basics 3 February 21st, 2006 05:30 AM
Dynamic Controls tommyuk VB How-To 2 June 26th, 2003 12:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.