|
-
Sep 12th, 2004, 09:29 PM
#1
Thread Starter
Lively Member
Preserving form controls when creating new instance of form!!
Let's say I have two forms, FormA & FormB. When creating a new instance of FormA in FormB I lose all controls that were created in FormA at runtime. I understand this b/c I'm creating a new instance!!
How can I preserve these controls so I can get at them from FormB? Is there another way besides creating a 'new' instance of FormA??
Thanks.
-
Sep 13th, 2004, 09:43 AM
#2
Addicted Member
wouldn't simply looping through FormB's control collection give you what you want
Code:
//FormB
foreach (ctrl in FormA.Controls)
{
Console.Writeline (ctrl.Name) //do something meaninful here
}
-
Sep 13th, 2004, 11:15 AM
#3
Thread Starter
Lively Member
I don't think so. I have a panel on FormA which can contain one or more usercontrols, depending on how many the user adds at runtime. If I attempt to get a 'count' of controls within the panel at runtime from FormB, I get "0" even though there have been several usercontrols added.
???
-
Sep 14th, 2004, 04:44 AM
#4
Addicted Member
Originally posted by Ksyrium
I get "0" even though there have been several usercontrols added.
???
odd...works for me.
to clarify. A form is populated with dynamic controls - you want to acess these controls from another form (the form that opens it)?
Last edited by powdir; Sep 14th, 2004 at 05:14 AM.
-
Sep 14th, 2004, 09:45 AM
#5
Addicted Member
Are you wanting to make a copy of the form or just copy the controls over to a new form?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|