public PropertyGrid() { onComponentAdd = new ComponentEventHandler(OnComponentAdd); onComponentRemove = new ComponentEventHandler(OnComponentRemove); onComponentChanged = new ComponentChangedEventHandler(OnComponentChanged); SuspendLayout(); AutoScaleMode = AutoScaleMode.None; if (!isScalingInitialized) { if (DpiHelper.IsScalingRequired) { normalButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_NORMAL_BUTTON_SIZE); largeButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_LARGE_BUTTON_SIZE); } isScalingInitialized = true; } try { gridView = CreateGridView(null); gridView.TabStop = true; gridView.MouseMove += new MouseEventHandler(this.OnChildMouseMove); gridView.MouseDown += new MouseEventHandler(this.OnChildMouseDown); gridView.TabIndex = 2; separator1 = CreateSeparatorButton(); separator2 = CreateSeparatorButton(); toolStrip = new ToolStrip(); toolStrip.SuspendLayout(); toolStrip.ShowItemToolTips = true; toolStrip.AccessibleName = SR.GetString(SR.PropertyGridToolbarAccessibleName); toolStrip.AccessibleRole = AccessibleRole.ToolBar; toolStrip.TabStop = true; toolStrip.AllowMerge = false; // This caption is for testing. toolStrip.Text = "PropertyGridToolBar"; // LayoutInternal handles positioning, and for perf reasons, we manually size. toolStrip.Dock = DockStyle.None; toolStrip.AutoSize = false; toolStrip.TabIndex = 1; toolStrip.ImageScalingSize = normalButtonSize; // parity with the old... toolStrip.CanOverflow = false; // hide the grip but add in a few more pixels of padding. toolStrip.GripStyle = ToolStripGripStyle.Hidden; Padding toolStripPadding = toolStrip.Padding; toolStripPadding.Left = 2; toolStrip.Padding = toolStripPadding; SetToolStripRenderer(); // always add the property tab here AddRefTab(DefaultTabType, null, PropertyTabScope.Static, true); doccomment = new DocComment(this); doccomment.SuspendLayout(); doccomment.TabStop = false; doccomment.Dock = DockStyle.None; doccomment.BackColor = SystemColors.Control; doccomment.ForeColor = SystemColors.ControlText; doccomment.MouseMove += new MouseEventHandler(this.OnChildMouseMove); doccomment.MouseDown += new MouseEventHandler(this.OnChildMouseDown); hotcommands = new HotCommands(this); hotcommands.SuspendLayout(); hotcommands.TabIndex = 3; hotcommands.Dock = DockStyle.None; SetHotCommandColors(false); hotcommands.Visible = false; hotcommands.MouseMove += new MouseEventHandler(this.OnChildMouseMove); hotcommands.MouseDown += new MouseEventHandler(this.OnChildMouseDown); Controls.AddRange(new Control[] { doccomment, hotcommands, gridView, toolStrip }); SetActiveControlInternal(gridView); toolStrip.ResumeLayout(false); // SetupToolbar should perform the layout SetupToolbar(); this.PropertySort = PropertySort.Categorized | PropertySort.Alphabetical; this.Text = "PropertyGrid"; SetSelectState(0); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { if (doccomment != null) { doccomment.ResumeLayout(false); } if (hotcommands != null) { hotcommands.ResumeLayout(false); } ResumeLayout(true); } }