c#-Visual Studio中的分组的自定义设计时间属性
作者:互联网
我以前曾问过类似的问题,但不完全是我要问的问题.
我有一个用户控件,并希望构建一堆可扩展的属性,以便在设计时编辑控件.请注意,不是一组属性,而是类似于“大小”或“位置”属性的属性列表,您可以打开它们以显示其他属性.这可能吗,我将如何去做呢?
谢谢,
解决方法:
您需要将属性“分组”到一个类中,然后应用TypeConverter:
[TypeConverter(typeof(ExpandableObjectConverter))]
public class MyProperties {
public string Item1 { get; set; }
public string Item2 { get; set; }
}
然后,您的UserControl将使用该类而不是其包含的单个属性:
public partial class UserControl1 {
public UserControl1() {
InitializeComponent();
MyProperties = new MyProperties();
}
public MyProperties MyProperties { get; set; }
}
创建自己的TypeConverter以处理自定义情况.
标签:design-time,properties,visual-studio-2010,c 来源: https://codeday.me/bug/20191031/1978672.html