Home > Net >  PropertyGrid control according to the array
PropertyGrid control according to the array

Time:10-17

Himself wrote a TypeConverter converts an array into a string
Do not use the TypeConverter effect

With the effects of the TypeConverter

I wanted to send a Double [] Array into a string, but after the transformation, the expansion of content is changed, is there any bosses know how


Private double [] exposeTime=new double [] {1, 2, 4};
[Browsable (true)]
[ReadOnly (false)]
[the Category (" camera parameters ")]
[DisplayName (" exposure ")]
[XmlElement (" exposure ")]
[TypeConverter (typeof (ArrayConverter)))
Public double [] ExposeTime
{
The get
{
Return exposeTime;
}
Set
{
ExposeTime=value;
}
}




Public class ArrayConverter: ExpandableObjectConverter
{



Public override the object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, System. The Type destinationType)
{

If (destinationType==typeof (System. String) & amp; & The value is a double [])
{
Var v=value as a double [];
String s=string. The Empty;
The foreach (var in a v)
{
S +=a.T oString () + ", ";
}
Return s.T rimEnd (', ');
}
Return to base. ConvertTo (context, culture, value, destinationType);

}
}

CodePudding user response:

Under the Model changes, don't use an array, try the enumeration.
Or you need to describe the ~
  •  Tags:  
  • C#
  • Related