winforms - C# simplifying generic user control -
i have implemented generic user command doing:
public class genericcontrol<t> : command {} public class customertypecontrolparent : genericcontrol<customertype> {} public class customertypecontrol : customertypecontrolparent {}
i'm doing above can place inherited command (customertypecontrol) in form designer. working fine. have on 50 such controls, , although of code contained within generic command itself, doesn't clean solution.
one problem can't utilize interface because, example, customertype exposes name , description fields, whilst productcategory exposes number , description. other entities expose different fields.
furthermore, don't want utilize 1 command , having long switch statement determine kind of object have, cast , appropriate fields.
i utilize above method can type.
so there cleaner approach above?
i think best practice have specific gui element each model or entity same type of data. 'name , description' seems different 'number , description' should have 2 separate gui controls. if should utilize same gui element, don't see why can't utilize interface this:
public interface itextanddescription { string text; string description; }
you implement customertype , productcategory , there go.
c# winforms user-controls
No comments:
Post a Comment