473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

inheritance

I have a UserControl that I want to inherit from. Actually, I want to base a
lot of controls on it. It exposes a lot of overridable methods, some of
which I don't want to forget to override; these, I would LIKE to make
MustOverride, but when I do (and therefore make my UserControl MustInherit),
all of my descendant UserControls no longer have a design interface. How can
I make my ancestor UserControl MustInherit while still retaining the design
interface for its children?

Thanks,

Pat
Nov 21 '05 #1
2 944
"pmcguire" <pm******@discussions.microsoft.com> schrieb:
I have a UserControl that I want to inherit from. Actually, I want to base
a
lot of controls on it. It exposes a lot of overridable methods, some of
which I don't want to forget to override; these, I would LIKE to make
MustOverride, but when I do (and therefore make my UserControl
MustInherit),
all of my descendant UserControls no longer have a design interface. How
can
I make my ancestor UserControl MustInherit while still retaining the
design
interface for its children?


You cannot. The designer will have to instantiate the base class in order
to show the designer.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
Pat,
As Herfried states, you cannot as the Designer needs to instantiate the base
class.

What I do is to throw a NotImplementedException in each of the "must
override" methods of the base, this way at run time if they are not
overridden then an exception occurs.

Additionally you can wrap the method in an #if/#else and make the method
MustOverride in Release builds, while simply overridable in Debug builds.
Something like:

#if Debug Then
Public Class FormBase
Inherits System.Windows.Forms.Form
#else
Public MustInherit Class FormBase
Inherits System.Windows.Forms.Form
#end if

#if Debug Then
Public Overridable Sub Method1()
Throw New NotImplementedException
End Sub
#else
Public MustOverride Sub Method1()
#end if

End Class

Hope this helps
Jay

"pmcguire" <pm******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
I have a UserControl that I want to inherit from. Actually, I want to base
a
lot of controls on it. It exposes a lot of overridable methods, some of
which I don't want to forget to override; these, I would LIKE to make
MustOverride, but when I do (and therefore make my UserControl
MustInherit),
all of my descendant UserControls no longer have a design interface. How
can
I make my ancestor UserControl MustInherit while still retaining the
design
interface for its children?

Thanks,

Pat

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.