views:

99

answers:

2

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!

A: 

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.

DefLog
I would rather not use an enum, especially since the numeric data types are a system stuct. Also the enums don't like to have reserved words used in them. Their must be a way to sovle this easily.???
Rick
I wouldn't call it easy but you can create a custom editor for a custom type in a propertygird. http://msdn.microsoft.com/en-us/library/ms171840.aspx shows how its done.
DefLog
A: 

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.

Rick