如果添加 Category, 自定义控件,会放在杂项中
命名空间 system.ComponentModel
public class Model
{
// 分组
[Category("通信")]
// 描述信息,就是 window中 属性,下面的解释信息。
[Description("设置IP地址")]
public string IP {get;set;}
}
propertyGrid
namespace WindowsFormsApp1
{
public class StudentModel
{
[Category("ZEN")]
[Description("学生姓名")]
public string Student_Name { get; set; }
[Category("ZEN")]
[Description("喜欢的颜色")]
public Color Favourite_Color { get; set; }
private Teacher teacherInfo;
// 显示下一级
[TypeConverter(typeof(ExpandableObjectConverter))]
//可编辑
[EditorBrowsable(EditorBrowsableState.Always)]
//描述信息
[Description("任课老师信息")]
//分组
[Category("Teacher信息")]
public Teacher TeacherInfo {
get {
if (teacherInfo ==null)
{
return teacherInfo = new Teacher();
}else {
return teacherInfo;
}
}
set {
teacherInfo = value;
}
}
}
public class Teacher
{
[Description("英语老师名字")]
public string EnglishName { get; set; }
[Description("数学老师名字")]
public string MathName { get; set; }
[Description("语文老师名字")]
public string ChineseName { get; set; }
public override string ToString()
{
return "TeacherInfo";
}
}
}