473,549 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An array of Controls on Main Form

Hi,

I want to create an array of combo boxes on my form.

The only problem is that I don't want to place 3 seperate combo boxes on
the form if I can avoid it. I'd just like to create an array and
dynamically create them. For example, like the code (that uses Radio
Buttons) below.

Can I do this and be able to position them on the form as well (even if
just in code). I would have to edit code that says "Form Designer Code -
Do not edit"... it all seems like it's not really feasible.
System.Windows. Forms.RadioButt on [] radioButtons = new
System.Windows. Forms.RadioButt on[3];

for(int i=0; i<3; ++i)
{
radioButtons[i] = new RadioButton();
radioButtons[i].Text = stringArray[i];
radioButtons[i].Location = new System.Drawing. Point(10, 10+i*20);
this.Controls.A dd(radioButtons[i]);
}
Nov 17 '05 #1
2 1845
Hello,
You don't need to change the InitializeCompo nent method code. You can
write this code in your form's constructor. you can also use
this.Controls.A ddRange(array) to add many controls at once.

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
Hello,
You don't need to change the InitializeCompo nent method code. You can
write this code in your form's constructor. you can also use
this.Controls.A ddRange(array) to add many controls at once.

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3

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

Similar topics

0
3082
by: Lauren Quantrell | last post by:
In terms of resources, wondering if it makes a difference in adopting one of the three options below for resizing controls on a form and controls on a subform at the same time. option a.) Put the code all in the main form and refer to the controls on the subform in the main form's OnResize event. option b.) Put the code for the main form...
3
14142
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. Thanks in advance, Chris
0
331
by: Spurry Moses | last post by:
Hi, I want to create an array of combo boxes on my form. The only problem is that I don't want to place 3 seperate combo boxes on the form if I can avoid it. I'd just like to create an array and dynamically create them. For example, like the code (that uses Radio Buttons) below. Can I do this and be able to position them on the form as...
15
5310
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have private string myArray;
5
3441
by: Brian Link | last post by:
The design of my app is such that I have a main form which loads a variety of user controls. Sometimes these controls will contain their own constituent sub-controls. The main form should respond to changes in the constituent controls, either by showing/hiding menus, or updating status bar text. Currently I'm rippling up events through...
4
3559
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is quite tiresome to have to write code to call MyControl.Invoke for each control on the form, along with the delegates that are required for each. Is...
2
14001
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the MDI child window. How can I make the MDI child window appear in front of any controls that may be on the MDI parent? thanks, John
4
9671
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person writing the JavaScript doesn't have to pass the index in the "onChange" event name. I thought that one might be able to use "this.value" or...
3
2741
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7965
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7817
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6051
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.