Custom Control with Data Type property Issue
-
03-07-2019 - |
Question
I'm building a custom user control. One of the properties must allow the end user to select the numeric data type such as int, short, long, double....
I'm having a problem figuring out what to use as an internal property type, so that when the user selects the DataType option in the property box it will give them a drop down list of all the numeric types.
I've tried a few variances... This one below, when compiled displays the DataType property as grayed out. It won't allow me to select or enter a value.
private System.ValueType _DataType;
public System.ValueType DataType
{
get { return _DataType; }
set
{
_DataType = value;
}
}
Any help is appreciated. Thanks!
Solution
The property editor has no idea how to edit the type. The easiest way to fix it is to use a type it does know how to edit, like a string or an enum. Enum probably fits best with what you are trying to accomplish.
OTHER TIPS
I ended up using an enum - I think their should be a better answer than this. Same functionality is found when designing datasets in the designer. When you select the data type you can choose int and others.