问题
I wish to allow the user of my control to choose the licensing method for the control. The choice comes from an enumeration, so they must choose one of the methods I have laid out for them. This license needs to be chosen prior to the code executing at runtime. Therefore I wish for them to selected a value at design time. Furthermore I do not wish for this property to be writable at runtime, if that can be avoided. Is there a way to make a property only available at design time?
回答1:
You can give a control design-time behavior by creating a separate designer class for the control. Since the control itself can only exist as an instance of your runtime, you can't really have a property directly on it which is set only at design-time (where would it get stored?). However, designer classes are only invoked and used by the designer, so you can encapsulate non-runtime behavior there.
来源:https://stackoverflow.com/questions/1345019/can-a-windows-forms-control-have-a-design-time-only-property