Controls Added To TabPages In Designer - How Do You Access?

G

Gary Brown

Hi,

How do you access controls that were added to a TabPage
in Designer? MS's documentation doesn't use Designer.
The example in TabControl defines them in the main form then
copies a reference to the TabControl's Controls property.
Walking though Controls looking for the control you want is
clumsy. Is there a better solution?

Thanks,
Gary
 
P

Peter Duniho

Gary said:
Hi,

How do you access controls that were added to a TabPage
in Designer? MS's documentation doesn't use Designer.
The example in TabControl defines them in the main form then
copies a reference to the TabControl's Controls property.
Walking though Controls looking for the control you want is
clumsy. Is there a better solution?

Better than what? As you've already noted, the actual control is
contained as a member field in the main form's class. You can access
the control directly via that member field, just like any other control
that is in the main form.

Pete
 
G

Gary Brown

Gary said:
Better than what? As you've already noted, the actual control is
contained as a member field in the main form's class. You can access the
control directly via that member field, just like any other control that
is in the main form.

Thanks. I hadn't considered that Designer does exactly what the
example did - adds the controls to the main form. But that creates
another problem because I need multiple instances of the same
page.

What I really need is tabbed MDI so I'm off in that direction.

Gary
 
P

Peter Duniho

Gary said:
Thanks. I hadn't considered that Designer does exactly what the
example did - adds the controls to the main form. But that creates
another problem because I need multiple instances of the same
page.

What I really need is tabbed MDI so I'm off in that direction.

How about making a custom control that derives from the TabPage class?
Your control would contain the controls as members within that class,
and could be accessed that way, as class instance members.

Tabbed MDI would probably work too. I guess it just depends on what
context you intend to use the controls/forms. If they are more like
documents or forms, I'd go with MDI, if they are more like tabs within a
form, I'd try to stick with the TabPage paradigm.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top