TabPage TabControl Question

M

meh

New to C#...
I have a tab page with a handful of controls on it (label, combobox, etc.).
Is it possible to "boilerplate a tabPage with the controls "like a MDI
childForm" so that adding a new tabPage includes the controls.
Any examples, documentation or comments would be helpful.


tia
meh
 
A

AlexS

Hi, meh

You have to use standard inheritance. As control is basically same old class
you can use something like this:

class BaseTabPage {
// here you define tab page and all the controls, which you need to be
present on this page and other pages
}

class NewTabPage : BaseTabPage {
// here you define only controls, which should exist in addition to ones
already defined in BaseTabPage
}

And then you instantiate your new pages with standard new:

NewTabPage tp1=new NewTabPage();

BaseTabPage in this case serves as "boilerplate" one.

I would suggest also to check any books on OO programming in .Net - they
usually are full of similar examples.

HTH
Alex
 
A

AlexS

Small correction -

class BaseTabPage : TabPage {
....
}

BaseTabPage should be based on TabPage, right?

HTH
Alex
 
M

meh

Thx Alex

So I was thinking in the right direction......

One more question. In this case it would be better to basically derive
(inherit?) a tabcontrol and the associated "boilerplate" tabpage into my
project...Correct?

tia
meh
 
A

AlexS

Hi, meh

basically - yes and no. Depends on how you plan to use templated controls.
TabControl contains a collection of TabPages. You can create and add new
pages derived from BaseTabPage. Same can be done with whole TabControl.
I am not sure what you want to do, so can't say if this is better or not.
Better than what?

HTH
Alex
 
M

meh

Thanks again Alex exactaly what I needed to know.
Now let's just see if I can do this.......Thanks again for the guidance

meh
 

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