[英]How does one have the C# designer know the default property for a Padding or other object/struct in C#
[英]How to let C# designer edit my struct property?
我在C#中使用多個自定義屬性創建自定義Windows窗體控件。 其中一個屬性是一個帶有幾個整數字段的簡單結構:
public struct Test
{
public int A, B;
}
Test _Test;
[Category("MyCategory")]
public Test TestProperty
{
get { return _Test; }
set { _Test = value; }
}
我希望Visual Studio設計器以與Size
, Margins
和其他類似Windows窗體結構相同的方式編輯結構的字段。 我是否需要基於UITypeEditor
類實現自定義屬性編輯器,或者.Net框架是否提供了一些常見的“結構編輯器”?
這應該做的伎倆:
[TypeConverter(typeof(ExpandableObjectConverter))]
public struct Test
{
public int _A, _B;
public int B
{
get { return _B; }
set { _B = value; }
}
public int A
{
get { return _A; }
set { _A = value; }
}
}
Test _Test;
[Category("MyCategory")]
public Test TestProperty
{
get { return _Test; }
set { _Test = value; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.