using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DemoCollection
{
public partial class FormPropertyGridControl : Form
{
public FormPropertyGridControl()
{
InitializeComponent();
}
private void FormPropertyGridControl_Load(object sender, EventArgs e)
{
CustomAttribute customAttribute = new CustomAttribute();
CustomAttribute1 customAttribute1 = new CustomAttribute1();
CustomAttribute2 customAttribute2 = new CustomAttribute2();
//实例化一个CustomAttribute1类型的对象,将它赋值给customAttribute的CA1属性
//这样CA1属性就会展示CustomAttribute1类型对象的属性成员
customAttribute.CA1 = customAttribute1;
customAttribute1.CustomDisplayFormart = customAttribute2;
propertyGridControl1.SelectedObject = customAttribute;//设置要展示属性的对象
propertyGridControl1.ExpandAllRows();//展开所有属性(包括子属性)
propertyGridControl1.RowHeaderWidth = 100;//设置自定义属性左边属性名称的宽度
//设置属性不按A-Z排序
propertyGridControl1.OptionsBehavior.PropertySort = DevExpress.XtraVerticalGrid.PropertySort.NoSort;
//设置属性按A-Z排序
//propertyGridControl1.OptionsBehavior.PropertySort = DevExpress.XtraVerticalGrid.PropertySort.Alphabetical;
DevExpress.XtraVerticalGrid.Rows.BaseRow br= propertyGridControl1.GetRowByCaption("自定义属性");
//通过循环遍历设置属性的中文名称
foreach (DevExpress.XtraVerticalGrid.Rows.PGridEditorRow per in br.ChildRows)
{
if (per.Chil
C#开发学习笔记:使用PropertyGridControl编写自定义属性
最新推荐文章于 2019-11-09 13:27:55 发布