473,672 Members | 3,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Dynamic Control Arrays

I have created a simple user control. On the parent form i would like to
display n instances of my usercontrol based on how many the user wants. How
would you do this in vb.net or c#.net. If this were an asp.net application i
think i could use something such as the repeater control.

Thanks.
--
Just another lost developer.....
Jul 21 '05 #1
2 1656
I am assuming this is a win form app. To add a control dynamically, just
instantiate the control type, ie MyControl ctlr = new MyControl, set the
properties you need, ie
ctrl.Location = new Point(x,y); etc. then add the control to the form's
controls collection, frm.controls.Ad d(ctrl); (or this.control if executing
within the form)

does this help?

Tom Wisnowski
MCP MCAD

"**** KiteOregon ****" wrote:
I have created a simple user control. On the parent form i would like to
display n instances of my usercontrol based on how many the user wants. How
would you do this in vb.net or c#.net. If this were an asp.net application i
think i could use something such as the repeater control.

Thanks.
--
Just another lost developer.....

Jul 21 '05 #2
int currentY = 10; // starting y location
for (int i = 0; i < numControls; i++)
{
Control c = new Control();
c.Location = new Point(x, currentY);
// other init
this.Controls.A dd(c);

currentY += 20;
}
"**** KiteOregon ****" wrote:
I have created a simple user control. On the parent form i would like to
display n instances of my usercontrol based on how many the user wants. How
would you do this in vb.net or c#.net. If this were an asp.net application i
think i could use something such as the repeater control.

Thanks.
--
Just another lost developer.....

Jul 21 '05 #3

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

Similar topics

2
345
by: **** KiteOregon **** | last post by:
I have created a simple user control. On the parent form i would like to display n instances of my usercontrol based on how many the user wants. How would you do this in vb.net or c#.net. If this were an asp.net application i think i could use something such as the repeater control. Thanks. -- Just another lost developer.....
4
2467
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... //trying to get input from the user to add all the numbers that user inputs //tried to do it without dynamic memory usage but probably cannot achieve it //here is using "new" and "delete" operator....
23
7397
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
4
11202
by: singleb | last post by:
I've tryed to something lik this and got "Object reference not set to an instance of an object." Dim myarr(,) As String myarr(0, 0) = "aaaa" myarr(0, 1) = "bbbb" myarr(1, 0) = "cccc" myarr(1, 1) = "dddd" Thanks.
5
3670
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of a particular radio button i making an ajax call using dojo and retirieving the data corresponding to that category. Now i am suppose to create array of that data using the javascript dynamically. Can anyone please help me for the same. For your...
1
4652
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3493
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
2
2240
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I am using vb.net 2005 and the following code trying to create varible at runtime: For n=1 to 4 dim v+n.tostring(n) as double Next n the resone behaind using the previous code is to create
4
5422
by: Sunny | last post by:
Hi, Is there a way in javascript to create Dynamic arrays or arrays on fly. Something Like: var "ptsgN"+sd = new Array(); Here sd is incrementing by 1. I have lots of data that I am putting in arrays.
0
8504
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8419
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8643
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8697
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7475
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6255
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5720
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1837
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.