Back to Devexpress

PropertyGridControl() Constructor

windowsforms-devexpress-dot-xtraverticalgrid-dot-propertygridcontrol-dot-ctor-099eeeb2.md

latest3.4 KB
Original Source

PropertyGridControl() Constructor

Initiliazes a new instance of the PropertyGridControl class with default settings.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
public PropertyGridControl()
vb
Public Sub New

Example

The following code creates a PropertyGridControl and makes it display its own properties.

By default, Boolean values are edited in the Property Grid Control using a ComboBox control with the True and False options. This example shows how to associate a CheckEdit control with the Boolean data type. As a result, the CheckEdit control will be used by default for editing Boolean values.

Firstly, a repository item (RepositoryItemCheckEdit) which corresponds to the CheckEdit control is created. Then it is associated with the Boolean type via the PropertyGridControl.DefaultEditors collection.

The following image shows the result. Notice that the created repository item is customized to represent traditional check boxes as radio buttons.

csharp
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraEditors.Repository;
// ...
PropertyGridControl pGrid = new PropertyGridControl();
this.Controls.Add(pGrid);
pGrid.SelectedObject = pGrid;
pGrid.Dock = DockStyle.Fill;
// Create a repository item which represents an in-place CheckEdit control.
RepositoryItemCheckEdit riCheckEdit = new RepositoryItemCheckEdit();
// Represent check boxes as radio buttons.
riCheckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Radio;
// Associate the Boolean data type with the created repository item.
pGrid.DefaultEditors.Add(typeof(Boolean), riCheckEdit);
vb
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraEditors.Repository
' ...
Dim pGrid As PropertyGridControl = New PropertyGridControl()
Me.Controls.Add(pGrid)
pGrid.SelectedObject = pGrid
pGrid.Dock = DockStyle.Fill
' Create a repository item which represents an in-place CheckEdit control.
Dim riCheckEdit As RepositoryItemCheckEdit = New RepositoryItemCheckEdit()
' Represent check boxes as radio buttons.
riCheckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Radio
' Associate the Boolean data type with the created repository item.
pGrid.DefaultEditors.Add(GetType(Boolean), riCheckEdit)

See Also

PropertyGridControl Class

PropertyGridControl Members

DevExpress.XtraVerticalGrid Namespace