I believe that the problem originates from the fact that you have
chosen an Abstract class (System.ValueType) as the type of the
property. I doubt if it is possible to do it this way. You should
instead use an enumeration of possible type names that your control
allows. Something like :
---
public enum AcceptableTypes
{
@Int16, // short
@Int32, // int
@Int64, // long
@Double, // double
}
---
You should then be able to convert the AcceptableType to a ValueType
for further processing:
---
using System.Globalization;
private AcceptableTypes _dataType;
private ValueType baseType;
public AcceptableTypes DataType
{
get { return _dataType; }
set
{
_dataType = value;
string typeName = "System." + Enum.GetName(typeof
(AcceptableTypes), value);
baseType = (ValueType)Convert.ChangeType(value, Type.GetType
(typeName), CultureInfo.InvariantCulture);
}
}
---
Hope this helps !
On Feb 27, 4:56 pm, GotDotNetNow <[email protected]> wrote:
> 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 a
> 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 display
> 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!