Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Inherited User Control not showing in designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee - 28 Dec 2004 05:41 GMT
I have a user control that inherits from another user control. The base user
control works fine in the designer, I can see all of the controls, etc...

However when I open the derived control in the designer, all I see is a grey
square with no controls. I have tried attaching to the IDE with another
instance's debugger, but no exceptions are being thrown when the control is
open.

Here is how the constructors are setup:

Base Control:

public class MyBase : System.Windows.Forms.UserControl
{
   [Browsable(false)]
   protected AnotherObject _oObject;
       
   [Browsable(false)]
   public AnotherObject oObject
   {
       get{ return _oObject; }
       set{ _oObject= value; }
   }

   public MyBase()
   {
       _oObject= new AnotherObject ();
   }

   public MyBase (AnotherObject oObject)
   {
       InitializeComponent();
       _oObject= oObject;
   }
}

Derived Control:

public class MyDerived: MyBase
{

   public MyDerived(AnotherObject oObject) : base(oObject)
   {
       InitializeComponent();
   }

   public MyDerived() : base()
   {
   }

}

Please help!
Lee - 28 Dec 2004 06:05 GMT
I have finally figured this out, if anyone else is having this problem, the
key is to make sure that the call to InitializeComponent is made in the
default constructor. I added the default constructor to correct the problem
where the designer couldn't create an instance, but without that call, none
of the controls are created.

Duh.

Lee

> I have a user control that inherits from another user control. The base user
> control works fine in the designer, I can see all of the controls, etc...
[quoted text clipped - 49 lines]
>
> Please help!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.