I would like to be able to create C# properties for a control class that will be displayed in the Visual Studio Properties Window in design mode. How do you create properties that are initialized for use in the Properties Window during design time?
For example, I would like to create a 'ComPort' property for a control class that would display as a drop-down list of available COM ports when the control is used during design mode.
The property listbox should be populated with the COM port names returned from the SerialPort
Code:
string[] ComPortNames = SerialPort.GetPortNames();
It's easy to create a ListBox property that displays as an empty drop-down list but how do I fill in its initial value from ComPortNames during design mode?
Code:
public ListBox ComPort {get; set;}
What is the general principle for initializing / setting initial values especially in regard to more more complex objects that are properties of control. For example, the BorderThickness or BorderBrush properties show more complex property selectors in the Properties Window.
Thanks for your help.