c# - Defining a Winform as abstract do not allow editing the UI of the derived Winforms -


i have base winform , 2 derived winforms. base winform contains labels, textboxes , save button. each derived class contains additional labels , textboxes. savebutton_click event calling save method. defined save method abstract in base class therefore defining base winform abstract.

here code:

public abstract partial class baserowinfo : form {     public baserowinfo()     {         initializecomponent();     }      private void savebutton_click(object sender, eventargs e)     {         save();     }      protected abstract void save(); }  public partial class editablerowinfofrm : baserowinfo {     public editablerowinfofrm():base()     {         initializecomponent();                 }      protected override void save()     {         // todo     } }  public partial class readonlyrowinfofrm : baserowinfo {     public readonlyrowinfofrm ():base()     {         initializecomponent();                 }      protected override void save()     {         // todo     } } 

once defining base class abstract, not have anymore ability edit ui of derived forms. fact defining base class abstract wrong? solution in case acceptable define abstract?

no, there nothing wrong approach. visual studio ide doesn't using abstract classes in editor.

i can understand microsofts point-of-view hard implement. risk changing base class. not sure how implement designer work in decent way.

there 2 options:

  • write ui code hand every deriving class;
  • add control, possibly implementing common interface communication, can add derived form. control can created using designer.

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -