473,503 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically creating form controls

Hi everyone :)
I'm a newb to C-Sharp but more I learn about it - more I like it.
I need some help please. I'm trying to find out to dynamically allocate
form controls. For example I want to have 5 combo boxes on my form and
I want to put the into an array.
Can someone point me to some good guide on how to do it or posibly post
'how to' ?
Thanks in advance.

Dec 14 '06 #1
1 1606

Vanyok wrote:
Hi everyone :)
I'm a newb to C-Sharp but more I learn about it - more I like it.
I need some help please. I'm trying to find out to dynamically allocate
form controls. For example I want to have 5 combo boxes on my form and
I want to put the into an array.
Can someone point me to some good guide on how to do it or posibly post
'how to' ?
There's really no need for a guide. Here's how.

Create your form, and add a couple of combo boxes using the Visual
Studio Designer. Now, switch to Code view. If you're using VS2003, open
the region of your C# file that says "Windows Form Designer generated
code" and look at what the Designer did for you. If you're using
VS2005, you have to find the partial class file that the Designer
generated and look at the code in there.

Once you've studied that code a bit and figured out what it does, just
cut and paste it into your application (e.g. the constructor of your
form, or the OnLoad method if you need to do something more intensive),
and adapt it to your needs.

I never to try to write code from scratch to put controls on the form
dynamically. Instead, I just find some Designer-generated code that is
sort of like what I want to do, copy, paste, and tweak. That way I know
it's right from the outset.

Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3006
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
2556
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
2
2893
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
6
3350
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
2
4548
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
5
3713
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
9
7026
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
4
2953
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
8
2794
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
1
4870
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.