PropertyGrid Class
Provides a user interface for browsing the properties of an object.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
'Declaration <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ <PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _ <PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> _ Public Class PropertyGrid _ Inherits ContainerControl _ Implements IComPropertyBrowser 'Usage Dim instance As PropertyGrid
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.
The PropertyGrid control is not initially presented in the toolbox in the development environment. You can add a property grid to the toolbox, which enables you to drag a PropertyGrid onto your form. You can also define an instance of PropertyGrid by adding the appropriate code in your source code.
All public properties of the SelectedObject will be displayed in the PropertyGrid by default. You can hide a property so that it is not displayed in the PropertyGrid control by decorating it with the BrowsableAttribute and setting the value to false. You can specify the category that a property appears in by providing a category with the CategoryAttribute. You can provide descriptive text for your property that appears at the bottom of the PropertyGrid control by using the DescriptionAttribute.
The following code example illustrates creating a property grid and setting its location on a form. This example requires that you have a form with a TextBox on it.
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
- SecurityAction
for full trust. Associated enumeration: LinkDemand.
- SecurityAction
for full trust. Associated enumeration: InheritanceDemand.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.