我尝试了e.Graphics.Clear并用白色笔刷将其绘制到图形中。但这不起作用。这是我的代码:
public class MyUITypeEditor : UITypeEditor
{
public override void PaintValue(PaintValueEventArgs e)
{
// Not working:
//e.Graphics.Clear(Color.White);
//using (SolidBrush brush = new SolidBrush(Color.White))
//{
// e.Graphics.FillRectangle(brush, e.Bounds);
//}
e.Graphics.DrawString(
"0|0, 10|10",
new Font("Arial", 10f, FontStyle.Bold),
new SolidBrush(Color.Black),
new Point(0, 0));
}
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return true;
}
}
答案 0 :(得分:0)
您要做的是定义一个新的TypeConverter
元素并覆盖以下方法:
public class test_typeconverter : TypeConverter
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
object value, Type destinationType)
=> "Text requiered";
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => true;
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => false;
}
然后,您必须将此类型定义为要在属性网格中显示的集合的类型转换器,如下所示:
[TypeConverter(typeof(test_typeconverter))]
public List<int> Values { get; set; }