solitaryclown

PropertyGrid控件使用

2023-04-24
solitaryclown

1. 代码

  1. Brand
    class Brand
     {
         [Category("属性")]
         [DisplayName("配方ID")]
         [ReadOnly(true)]
         public int Id { get; set; }
         [Category("属性")]
         [DisplayName("配方名称")]
         public string Name { get; set; }
    
         [Category("属性")]
         [DisplayName("配方说明")]
         public string Description { get; set; }
    
         //一般参数
         [Category("参数")]
         [DisplayName("极柱个数")]
         public int numOfPole
         {
             get;set;
         }
         public Brand()
         {
         }
         public Brand(int id, string name, string description)
         {
             Id = id;
             Name = name;
             Description = description;
         }
     }
    
  2. Form
      public partial class Form1 : Form
     {
         public Form1()
         {
             InitializeComponent();
             Brand brand = new Brand();
             brand.Id = 1;
             brand.Name = "1P18";
             brand.Description = "1P18芯配方";
             this.propertyGrid1.SelectedObject = brand;
         }
     }
    

    2. 运行效果

    p9m8CtJ.png


上一篇 多线程

下一篇 CPP引用变量

Comments

Content