Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2007, 06:53 AM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default where are my childcontrols in the childcontrol??

I am trying to programmatically generate a form where I in design time have put a flowpanel in the form and in this flowpanel, depending on user input, generate several controls of my own(UserControl1 containing 2 textboxes, 2labels). Now the problem is that I cant reach the textboxes and labels to programmatically update nor get data from them. I am trying to use
a generic list where I in a loop store initiated usercontrol1. I add them to the flowLayoutPanel:

                //for loop
                UserControl1 tmpUC = new UserControl1();
                fcList.Add(tmpUC);
                this.flowLayoutPanel1.Controls.Add(tmpUC);
                //end loop

The flowLayoutPanel is then added to the form control:

this.Controls.Add(flowLayoutPanel1);

Then the problem appears...I cant get to the childcontrols of the UserControl1, through iterating the List.

            foreach(UserControl1 uc in fcList){
                uc.GetNextControl(textBox2, true);
            }

Following error: The textBox2 does not exist in the current context.

My goal: I want to be able to generate a form with my own usercontrol. This usercontrol contains 5 controls. How can I reach those controls to update them??

I am stuck for days with this problem....please help!

(please tell if my problemspecification is poor)

Thank you
platinumrx
 
Old February 5th, 2007, 03:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I don't really follow your problem, but want to make this point:

Remember that the Controls collection is a tree structure. So you may need to recurse the collection to find the control you are looking for.

-Peter









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.