how do i put an abstract property in base form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • parez

    #1

    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 NotImplementedE xception();" in the base form
    property. then i will find out at runtime rather than compile time.

    TIA
  • Peter Duniho

    #2
    Re: how do i put an abstract property in base form

    On Thu, 05 Jun 2008 13:08:10 -0700, parez <psawant@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 NotImplementedE xception();" 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

    Comment

    • parez

      #3
      Re: how do i put an abstract property in base form

      On Jun 5, 4:38 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.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 NotImplementedE xception();" 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

      Comment

      Working...