コード例 #1
0
        public PropertyGrid()
        {
            InitializeComponent();

            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                WinFormsPropertyGrid.Visible = false;
            } else WinFormsPropertyGrid.Visible = true;

            Loaded += (o, e) =>
            {
                WinFormsPropertyGrid.SelectedObject = PropertyObject;
            };

            WinFormsPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized;
            _lastSort = WinFormsPropertyGrid.PropertySort;

            var toolstrip = WinFormsPropertyGrid.Controls.OfType<ToolStrip>().First();
            var categoryButton = toolstrip.Items[0] as ToolStripButton;
            var alphaButton = toolstrip.Items[1] as ToolStripButton;
            categoryButton.Click += (o, e) =>
            {
                if (WinFormsPropertyGrid.PropertySort != PropertySort.NoSort && (_lastSort == PropertySort.Categorized || _lastSort == PropertySort.CategorizedAlphabetical))
                {
                    WinFormsPropertyGrid.PropertySort = PropertySort.NoSort;
                }
                else
                {
                    WinFormsPropertyGrid.PropertySort = PropertySort.Categorized;
                }
               _lastSort = WinFormsPropertyGrid.PropertySort;
            };

            alphaButton.Click += (o, e) =>
            {
                if (WinFormsPropertyGrid.PropertySort != PropertySort.NoSort && _lastSort == PropertySort.Alphabetical)
                {
                    WinFormsPropertyGrid.PropertySort = PropertySort.NoSort;
                }
                _lastSort = WinFormsPropertyGrid.PropertySort;
            };

            WinFormsPropertyGrid.PropertySortChanged += (o, e) =>
            {
                if (WinFormsPropertyGrid.PropertySort == PropertySort.CategorizedAlphabetical)
                    WinFormsPropertyGrid.PropertySort = PropertySort.Categorized;
            };

            //WinFormsPropertyGrid.ToolbarVisible = false;
        }
コード例 #2
0
 protected GridEntry(PropertyGrid owner, GridEntry peParent)
 {
     this.parentPE = peParent;
     this.ownerGrid = owner;
     if (peParent != null)
     {
         this.propertyDepth = peParent.PropertyDepth + 1;
         this.PropertySort = peParent.PropertySort;
         if (peParent.ForceReadOnly)
         {
             this.flags |= 0x400;
         }
     }
     else
     {
         this.propertyDepth = -1;
     }
 }