473,508 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do i put an abstract property in base form

how do i put an abstract property ( or something that lets me know
that derived class has not implemented that particular property ) in
base form in my win forms project?

if i make the base form abstract then i cannot use the designer?

I could use "throw new NotImplementedException();" in the base form
property. then i will find out at runtime rather than compile time.

TIA
Jun 27 '08 #1
2 1724
On Thu, 05 Jun 2008 13:08:10 -0700, parez <ps*****@gmail.comwrote:
how do i put an abstract property ( or something that lets me know
that derived class has not implemented that particular property ) in
base form in my win forms project?

if i make the base form abstract then i cannot use the designer?
Well, you can't use the designer with the base class, that's right. It
might prevent using the designer from a derived class too, but you should
check that before worrying about it. I recall some specific rules about
how sub-classed sub-classes of the Form class work with the Designer, but
don't remember the specifics. :)

Have you run into some specific problem using the Designer with a
sub-class of an abstract class?
I could use "throw new NotImplementedException();" in the base form
property. then i will find out at runtime rather than compile time.
Yes, you could, for a virtual (not abstract) property. Of course, that
would rely on some code actually _using_ the property for you to find out
it hadn't been implemented. A less-risky alternative, though perhaps a
bit more "hacky", would be to include some code in the constructor of the
base class that uses reflection to look for a sub-class implementation of
the property in question.

Pete
Jun 27 '08 #2
On Jun 5, 4:38 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Thu, 05 Jun 2008 13:08:10 -0700, parez <psaw...@gmail.comwrote:
how do i put an abstract property ( or something that lets me know
that derived class has not implemented that particular property ) in
base form in my win forms project?
if i make the base form abstract then i cannot use the designer?

Well, you can't use the designer with the base class, that's right. It
might prevent using the designer from a derived class too, but you should
check that before worrying about it. I recall some specific rules about
how sub-classed sub-classes of the Form class work with the Designer, but
don't remember the specifics. :)
Yes. When i said "i cannot use the desinger", I meant all the
derived forms forms. I lost a few sentences between the thinking and
the typing. ;)

Actually the base form works just fine.

Have you run into some specific problem using the Designer with a
sub-class of an abstract class?

I get an error message of the type "the designer must have an instance
of the type..blah blah .. but it cannot because its an abstract type"
I could use "throw new NotImplementedException();" in the base form
property. then i will find out at runtime rather than compile time.

Yes, you could, for a virtual (not abstract) property. Of course, that
would rely on some code actually _using_ the property for you to find out
it hadn't been implemented.
This property would be used in the FormActivated event in the base
form so i would know right away when the form shows if it is not
implemented and fix it right away.

A less-risky alternative, though perhaps a
bit more "hacky", would be to include some code in the constructor of the
base class that uses reflection to look for a sub-class implementation of
the property in question.

I was looking for a compile time check.
Pete
Jun 27 '08 #3

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

Similar topics

2
2772
by: Yasutaka Ito | last post by:
Hi folks! I have a BaseForm class that inherits System.Windows.Forms.Form. It has a property, whose value I need supplied by the class that inherits it. The BaseForm usees the value supplied...
1
4828
by: J.Marsch | last post by:
I am trying to create a base form that all of our application's forms will inherit from. I would like to mark it "abstract", but if I do, I get an error from the form designer when I try to design...
2
9363
by: Joe Vrba | last post by:
I'm building a family of components derived from UserControl. There's an abstract base class to ensure basic functionality and then numerous other controls derived from that. The problem is...
33
3314
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
4
3525
by: Chuck Bowling | last post by:
I am using CodeDOM to generate source files. The classes being generated have a const string member. This member is referenced in an abstract base class but declared in the inheriting class. I...
9
5178
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
4
1254
by: Confused Newbie | last post by:
I'm converting an app written in VB 2003 to 2005 and need advice for how to deal with this situation: The app has a number of "manager" classes that handle the data access. They all have...
20
4006
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
5
2213
by: Tony Johansson | last post by:
Hello! Here I have an Interface called ITest and a class called MyClass which derive this intrface. As you can see I don't implement this method myTest in class MyClass because i use the...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
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...
1
7067
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...
1
5060
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...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.