简体   繁体   中英

Multiple abstract form inheritance

I have an abstract base control BaseControl for which I resolved the non-display of the child forms using the following post .

Now, I have a lot of controls sharing some common properties for which I want to create an intermediate abstract class to regroup the different common properties and force all descendants to implement some other properties.

[TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<BaseControl, UserControl>))]
public abstract partial class BaseControl : UserControl {
  ...
  ...
  ...
}
 [TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<BaseControl2, BaseControl>))]
public abstract partial class BaseControl2 : BaseControl {
  ...
  ...
  ...
}

Unfortunately, this doesn't work, the designer complains about not being able to create an instance of abstract class BaseControl2 for my descendant controls.

Any suggestion of how to resolve this?

You need to realize how the AbstractControlDescriptionProvider works - if the type is abstract, it replaces it with the non-abstract base type.

You specified an abstract type as the non-abstract base type, so obviously it can't work :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM