hmm, still no joy. These objects are to sit on a TabPage, on my main form, so
I presume as I create them I need to add them to the controls collection for
that tabpage, yes? So I did this:
foreach(Control ctTemp in ProcessAO.ObjectArray){
Control ctObj = new
Control(ctTemp.Text,ctTemp.Left,ctTemp.Top,ctTemp.Width,ctTemp.Height);
tpWizard2.Controls.Add(ctObj);
}
when I run it though I can see no controls at all on this page. If I debug
and foreach through each control on my tpWizard page I can see that they are
all there, but they are not visible. Am I forgetting something? Or am I
doing things in the wrong order?
Thanks
Steve
"Jon Skeet [C# MVP]" wrote:
> Steve <(E-Mail Removed)> wrote:
> > I have a 2 page Tab Control for users to add a Job in my application. The
> > first page is for them to choose which type of Job they would like. The type
> > of Job determines what information is asked for on the second page, and so
> > will determine the layout of the second page. So this second page needs to
> > be determined at runtime really when they select the Job Type on page 1. I
> > thought I could maybe define all the controls (Labels, Buttons, TextBoxes,
> > ComboBoxes etc) in seperate class file, then when they make their selection
> > on page 1, I instantiate this class and create the objects on my tabpage.
>
> Sure.
>
> > Is this possible? If so how?
> >
> > I have a PlumbJob.cs which has in it 2 TextBoxes and 2Labels defined, these
> > have their appropriate locations, sizes names etc defined in the PlumbJob.cs,
> > and then I have public ArrayList with this objects in it.
> >
> > When I select the JobType on TabPage1 I initialize this class, and scroll
> > through the Controls in this ArrayList, and try and create instances of them
> > on my TabPage like this:
> >
> > foreach(Control ctTemplate in PlumbJob.ObjectArray)
> > {
> > Control obj = new
> > Control(tpWizard2,ctTemplate.Text,ctTemplate.Left,ctTemplate.Top,ctTemplate.Width,ctTemplate.Height);
> > obj.Name = ctTemplate.Name;
> > obj.Visible = true;
> > }
> >
> > but I cant see the objects on my tab page. Any ideas?? Is this a viable way
> > of doing what I am trying to achieve?
>
> That's creating controls, but not adding them to anything. You probably
> want to use Controls.Add for each newly created control, to add them to
> the current form's list of controls.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>