日期:2014-05-18 浏览次数:21112 次
//PropertyGrid pg;
//pg.SelectedObject = new Car();
public class HeightConvert : TypeConvert
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
//...
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
//...
}
}
public class Car
{
[TypeConvert(typeof(HeightConvert))]
public int Height{get;set;}
}
public class Tx
{
int val = 0;
public int Value
{
get
{
return val;
}
set
{
if (value >= 0 && value <= 100)
{
val = value;
}
else
{
throw new Exception("数值有效范围为[0,100]");
}
}
}
}