Export (0) Print
Expand All
2 out of 27 rated this helpful - Rate this topic

PropertyGrid Class

Provides a user interface for browsing the properties of an object.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class PropertyGrid : ContainerControl, IComPropertyBrowser
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class PropertyGrid extends ContainerControl implements IComPropertyBrowser
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class PropertyGrid extends ContainerControl implements IComPropertyBrowser

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.

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 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;
}

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.ContainerControl
            System.Windows.Forms.PropertyGrid
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.