Re: Why must the designer create an instance of my control's absract base class?
Brady Kelly <[email protected]> Thu, 25 Oct 2007 16:47:45 +0200
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Thanks, it does, but I've found a wonderful workaround using TypeDescriptor and a custom TypeDescriptionProvider. The designer gets type information on your types from TypeDescriptor, and your custom provider can hoodwink it into instantiating your derived class instead of the base class. Read all about it here: http://www.urbanpotato.net/default.aspx/document/2001 > -----Original Message----- > From: Discussion forum for developers using Windows Forms to build apps > and controls [mailto:[email protected]] On Behalf Of > Andy Langowitz > Sent: 25 October 2007 04:24 PM > To: [email protected] > Subject: Re: [DOTNET-WINFORMS] Why must the designer create an instance > of my control's absract base class? > > On Wed, 24 Oct 2007 21:32:31 +0200, Brady Kelly > <[email protected]> > wrote: > > >I'm not asking it to create an instance of the base class, just the > derive > >class. Can anyone tell me why this is so? > > I have also been annoyed at this behavior, which means you cannot > extend an > abstract class when writing a designer-supported object, so I have > thought > about it in the past. > > Here's a possible explanation (I'm not a MS person, so I'm making an > educated guess): > > The designer is responsible for generating code (in the > InitializeComponents > method) that is called from your class's constructor. Hence, it cannot > invoke your class's constructor until it has completed its code > generation > (which came first, the chicken or the egg?). However, it needs to find > out > things about the class (such as its superclass public properties), so > that > is presumably why it invokes a constructor on the base class. > > Does this make sense? > > Andy Langowitz