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

Inheriting from Base Classes (Public Interfaces)

P: n/a
I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.

I have defined IComponentBase in a common assembly so that my other projects
reference this rather than the (large) library that contains the component
implementation.

[Stop me when I start to go off the rails]

Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.

So that I can attach to the MouseEnter event, and others, I find that I have
to define a MouseEnter event in my interface, implement it in my base class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.

I also find that if I want to refer to the Width property of UserControl, I
have to define it in my interface and override it in my base class.

This seems like a lot of code that, basically, just passes things on to the
UserControl base class, and it is very tedious and, of course, error prone.

Am I going about this the right way, or is there an easier solution?

TIA

Charles
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Doesent sound too maintainable to me. It also sounds like hard work, Im
simply too lazy, if it was giving me performance problems, I would probably
specify faster computers.

I know thats not the answer you were expecting. Good Luck !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Charles Law" <bl***@nowhere.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.
I have defined IComponentBase in a common assembly so that my other projects reference this rather than the (large) library that contains the component
implementation.

[Stop me when I start to go off the rails]

Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.

So that I can attach to the MouseEnter event, and others, I find that I have to define a MouseEnter event in my interface, implement it in my base class, and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.

I also find that if I want to refer to the Width property of UserControl, I have to define it in my interface and override it in my base class.

This seems like a lot of code that, basically, just passes things on to the UserControl base class, and it is very tedious and, of course, error prone.
Am I going about this the right way, or is there an easier solution?

TIA

Charles

Nov 20 '05 #2

P: n/a
Aaarrgh! }-:-|-[

---
I used a spell checker, and apparently 'Earth' comes a close second.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Doesent sound too maintainable to me. It also sounds like hard work, Im
simply too lazy, if it was giving me performance problems, I would probably specify faster computers.

I know thats not the answer you were expecting. Good Luck !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Charles Law" <bl***@nowhere.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.

I have defined IComponentBase in a common assembly so that my other

projects
reference this rather than the (large) library that contains the component implementation.

[Stop me when I start to go off the rails]

Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top, etc. I also get events like LocationChanged, MouseEnter, and so on.

So that I can attach to the MouseEnter event, and others, I find that I

have
to define a MouseEnter event in my interface, implement it in my base

class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and raise my event, which shadows the one in UserControl. It seems that I have to do this for every event I want to attach to.

I also find that if I want to refer to the Width property of

UserControl, I
have to define it in my interface and override it in my base class.

This seems like a lot of code that, basically, just passes things on to

the
UserControl base class, and it is very tedious and, of course, error

prone.

Am I going about this the right way, or is there an easier solution?

TIA

Charles


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.