473,657 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make an array of Forms

snehil
19 New Member
Hey,
Can any one help me with this problem.. i'ld really appreciate ne help..
wat i wanna do is.. dat i want to dynamically create objects on a way that they could be created in a loop..
so i thot an array of object could help
so i went ahead and wrote this code in a form load event..
Expand|Select|Wrap|Line Numbers
  1. Form1[] formarray = new Form1[4];
  2. for (int i = 0; i < 4; i++)
  3.     {
  4.         formarray[i] = new Form1();
  5.         formarray[i].Show(); 
  6.     }
  7.  

but at the line

Expand|Select|Wrap|Line Numbers
  1. formarray[i].Show(); 
I get this exception
Error creating window handle.
As u mite have guessed from the code.. wat i wanna do is to open 'n' no. of forms while loading.. and n will differ every time .. actually it will depend upon the no of records in some table and i want the no. of forms to be equal to the no. of records.
Aug 28 '10 #1
1 5175
GaryTexmo
1,501 Recognized Expert Top Contributor
I reproduced your code (kinda... more in a sec) and it actually worked fine. Maybe post more details... specifically, the full source?

I noticed you had it in the Form's Load event. Is Form1 your main form or another form? Obviously it's going to produce an infinite, exponential loop as each form would generate four new forms. However, it still worked and I didn't get an exception ;)
Aug 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2208
by: LRW | last post by:
I did a Web search, and a deja.com search on this...and I'm finding how to make checkboxes act like radiobuttons, and other interesting behaviors, but nothing that quite answers my question. If someone has a link or thread they know about, even just that would be great! What I have is a page that generates a list of items from a database...a list of rows. I'm having each row in the WHILE array create a checkbox, so that someone can put...
5
6516
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with the object references. However, I just realized that indices may only be referenced by strings.
8
2383
by: Gustaf Liljegren | last post by:
I'd like a simple way of extracting everything that's not whitespace on each line in a file. For example, if the program encounters this line 1 2\t\t3 \t\t4 I want a string array like this {"1", "2", "3", "4"} I tried working with String.Split() but found that it doesn't automatically
1
1349
by: Magnus Gran-Jansen | last post by:
Hi, I am trying to make my C# application of windows forms (hosted in IE by using UserControl) to connect to a port on the machine the "applet" is downloaded from. It would be useful if I could do this without changing the local security settings and it would also be nice to have a way of acquiring the server's IP address in an easy manner. Does anyone know how? Thanks, Magnus Gran-Jansen
1
1634
by: ad | last post by:
I select a single field from a table of database, like: Select distinct EmployeeID from Employee. Have there any convenient to throw the result of select items into a static array? or I must iterate throw the select result to add selected item into a dynamic array?
2
2070
by: Ken Allen | last post by:
I just upgraded to Visual Studio .NET and I'm impressed with the ease you can do some otherwise time consuming tasks. I've noticed that when making nonrectangular forms using the transparencykey property that it doesn't work in 32 bit mode. Is there a way to make it work in 32 bit or would I have to write my own method for transparency to get around this?
9
1585
by: Steve | last post by:
Hello, I created a structure ABC and an array of type ABC Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure Public ABC1 As New ABC, ABC2 As New ABC
22
20724
by: bela | last post by:
Hello, I am very new to JAVA. I would like to know, how to read *.csv file from java and how to save that data into an array. regards, bela
3
6121
by: raylopez99 | last post by:
I suspect the answer to this question is that it's impossible, but how do I make the below code work, at the point where it breaks (marked below). See error CS0411 This is the complete code. Copy and paste it into VS2008 for a Windows Forms application. With some effort I can do the job with a user defined function, but my question is whether I can do it using the built in library function "Array.Find" and a predicate that takes...
8
5843
by: Sunny | last post by:
Hi, Can someone tell me, How to redefine array or make array empty or null. Here what I am trying to do. var temp = new Array(); for(i=0; i <=outstring.length-1; i++) { temp = outstring.split(','); } Once the for loop will finish doing it, I want temp array to be null
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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
8605
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
7327
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
6164
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
4152
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1615
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.