Chapter 8. Property Grids
Many applications need to present sets of information that can be
edited. The data could be patient details in a healthcare system,
shape attributes in a drawing program, control properties in a form
designer, or any number of other kinds of information. Windows Forms
provides a control that makes presenting and editing such data easy,
while allowing great flexibility in the way in which information is
presented—the PropertyGrid
control.
Visual Studio .NET itself uses the
PropertyGrid
control to
present properties for all controls and other components in the Forms
Designer. This means that even if you don’t plan to
use a PropertyGrid
directly in your own
applications, it is helpful to have a good understanding of how it
works so you may control the way your components’
properties are presented. Visual Studio .NET lets you customize the
appearance of the property pages for your components using the
techniques described here.
In this chapter, we will start by looking at how to display the
properties of a simple object in a PropertyGrid
.
Then, we will see how to enable editing of custom types by using type
converters. Finally, we will see how to add our own custom property
editing user interfaces for when a text-based representation is
insufficient.
Displaying Simple Objects
The
PropertyGrid
makes it remarkably easy to provide an interface for editing the properties of an object. It uses the CLR’s reflection facility to discover what properties are available ...
Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.