By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

TabPage TabControl Question

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

"meh" <no*************@cox.net> wrote in message
news:eH*************@TK2MSFTNGP10.phx.gbl...
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

Nov 16 '05 #2

P: n/a
Small correction -

class BaseTabPage : TabPage {
....
}

BaseTabPage should be based on TabPage, right?

HTH
Alex

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
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

"meh" <no*************@cox.net> wrote in message
news:eH*************@TK2MSFTNGP10.phx.gbl...
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


Nov 16 '05 #3

P: n/a
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

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Small correction -

class BaseTabPage : TabPage {
...
}

BaseTabPage should be based on TabPage, right?

HTH
Alex

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
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

"meh" <no*************@cox.net> wrote in message
news:eH*************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 16 '05 #4

P: n/a
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

"meh" <no*************@cox.net> wrote in message
news:eN***************@TK2MSFTNGP12.phx.gbl...
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

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Small correction -

class BaseTabPage : TabPage {
...
}

BaseTabPage should be based on TabPage, right?

HTH
Alex

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
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

"meh" <no*************@cox.net> wrote in message
news:eH*************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 16 '05 #5

P: n/a
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

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

"meh" <no*************@cox.net> wrote in message
news:eN***************@TK2MSFTNGP12.phx.gbl...
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

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
> Small correction -
>
> class BaseTabPage : TabPage {
> ...
> }
>
> BaseTabPage should be based on TabPage, right?
>
> HTH
> Alex
>
> "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
> news:u0**************@TK2MSFTNGP09.phx.gbl...
>> 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
>>
>> "meh" <no*************@cox.net> wrote in message
>> news:eH*************@TK2MSFTNGP10.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>



Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.