Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Deriving with "heavy" constructors

Deriving with "heavy" constructors

Scheduled Pinned Locked Moved C#
visual-studiocsharpdesignhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EdgarBM
    wrote on last edited by
    #1

    Hi, we're creating a class scheme which needs to keep the properties instances from the childs classes on the main base class. To do this we're passing the instance of each class once by each child constructor to the main one, I mean: class child (propertyX A) : base (A) {...} ...this way we pass the instance of one property to the child class when it's instanced so the base class will get it. It works. The only problem is that the VS.NET IDE doesn't shows the child window in the design mode, getting an Exception message explaining that there's no instance of the base object or other strange messages like this. Does anyone knows a solution or a cause? Thank you in advance, Edgar Edgar Berengena Moreno Software Engineer Appeyron Research

    L 1 Reply Last reply
    0
    • E EdgarBM

      Hi, we're creating a class scheme which needs to keep the properties instances from the childs classes on the main base class. To do this we're passing the instance of each class once by each child constructor to the main one, I mean: class child (propertyX A) : base (A) {...} ...this way we pass the instance of one property to the child class when it's instanced so the base class will get it. It works. The only problem is that the VS.NET IDE doesn't shows the child window in the design mode, getting an Exception message explaining that there's no instance of the base object or other strange messages like this. Does anyone knows a solution or a cause? Thank you in advance, Edgar Edgar Berengena Moreno Software Engineer Appeyron Research

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Hi, For that too work you are gonna need a default constructor, in fact for any designer to work, you will need the default constructor. The default constructor is a constructor that takes no arguements. In your case, you could do this: public DerivedControl():base("some value here") { this.var1 = default1; this.var2 = default2; } UPDATE: Note this is only really for designer support. At runtime use your own construtors. :) Hope this helps :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

      R 1 Reply Last reply
      0
      • L leppie

        Hi, For that too work you are gonna need a default constructor, in fact for any designer to work, you will need the default constructor. The default constructor is a constructor that takes no arguements. In your case, you could do this: public DerivedControl():base("some value here") { this.var1 = default1; this.var2 = default2; } UPDATE: Note this is only really for designer support. At runtime use your own construtors. :) Hope this helps :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

        R Offline
        R Offline
        Ryan Cromwell
        wrote on last edited by
        #3

        You know I was extremely irritated when I had the same problems earlier. Thanks for the tip...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups