PropertyGrid Class
Provides a user interface for browsing the properties of an object.
For a list of all members of this type, see PropertyGrid Members.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
System.Windows.Forms.PropertyGrid
[Visual Basic] Public Class PropertyGrid Inherits ContainerControl [C#] public class PropertyGrid : ContainerControl [C++] public __gc class PropertyGrid : public ContainerControl [JScript] public class PropertyGrid extends ContainerControl
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
To use the property grid, you create a new instance of the PropertyGrid class on a parent control and set SelectedObject to the object to display the properties for.
The information displayed in the grid is a snapshot of the properties at the time the object is assigned. If a property value of the object specified by the SelectedObject is changed in code at run time, the new value is not displayed until an action is taken in the grid that causes the grid to refresh.
The property tabs within the property grid appear as buttons on the toolbar at the top of the PropertyGrid, and can vary in scope as defined in the PropertyTabScope enumeration.
The PropertyGrid control is not initially presented in the toolbox in the development environment. You can add a property grid to the toolbox, which allows you to drag and drop a PropertyGrid object onto your form. You can also define an instance of PropertyGrid by adding the appropriate code in your source code.
Example
[Visual Basic, C#, C++] The following example illustrates creating a property grid and setting its location on a form. This example assumes a form of with a TextBox on it.
[Visual Basic] Public Sub New() ' The initial constructor code goes here. Dim propertyGrid1 As New PropertyGrid() propertyGrid1.CommandsVisibleIfAvailable = True propertyGrid1.Location = New Point(10, 20) propertyGrid1.Size = New System.Drawing.Size(400, 300) propertyGrid1.TabIndex = 1 propertyGrid1.Text = "Property Grid" Me.Controls.Add(propertyGrid1) propertyGrid1.SelectedObject = textBox1 End Sub [C#] public Form1() { // The initial constructor code goes here. PropertyGrid propertyGrid1 = new PropertyGrid(); propertyGrid1.CommandsVisibleIfAvailable = true; propertyGrid1.Location = new Point(10, 20); propertyGrid1.Size = new System.Drawing.Size(400, 300); propertyGrid1.TabIndex = 1; propertyGrid1.Text = "Property Grid"; this.Controls.Add(propertyGrid1); propertyGrid1.SelectedObject = textBox1; } [C++] public: Form1() { // The initial constructor code goes here. PropertyGrid* propertyGrid1 = new PropertyGrid(); propertyGrid1->CommandsVisibleIfAvailable = true; propertyGrid1->Location = Point(10, 20); propertyGrid1->Size = System::Drawing::Size(400, 300); propertyGrid1->TabIndex = 1; propertyGrid1->Text = S"Property Grid"; this->Controls->Add(propertyGrid1); propertyGrid1->SelectedObject = textBox1; }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Windows.Forms
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
See Also
PropertyGrid Members | System.Windows.Forms Namespace | PropertyTabScope