TabPage TabControl Question

  • Thread starter Thread starter meh
  • Start date Start date
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
 
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
 
Small correction -

class BaseTabPage : TabPage {
....
}

BaseTabPage should be based on TabPage, right?

HTH
Alex
 
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
 
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
 
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
 
Back
Top