Skip to main content

PropertyGridControl.GetPropertyDescriptor(BaseRow) Method

Returns the property descriptor for the property associated with the specified row.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v23.2.dll

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

Declaration

public PropertyDescriptor GetPropertyDescriptor(
    BaseRow row
)

Parameters

Name Type Description
row BaseRow

A BaseRow object which is bound to the required property.

Returns

Type Description
PropertyDescriptor

A PropertyDescriptor value.

Example

The following example shows how to get information on the property which corresponds to the currently selected row in a PropertyGridControl.

Assume that the form contains PropertyGridControl and Button controls. The Property Grid Control is used to browse the button’s properties. It’s required to get information on the current Property Grid Control focused property and to display it onscreen.

In the example the VGridControlBase.FocusedRowChanged event is handled to track the row focus movement in the PropertyGridControl.

The PropertyGridControl.GetPropertyDescriptor method is called to get information on the currently focused row. This includes the current property’s name and description, and the object to which the property belongs. After the information has been obtained it’s displayed within two labels, which are positioned below the PropertyGridControl. The following images illustrate the results.

The button’s Cursor property is selected:

VertGrid_GetPropertyDescriptor_Ex_SelectCursor

The button’s FlatAppearance.BorderColor property is selected:

VertGrid_GetPropertyDescriptor_Ex_SelectBorderColor

using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
using DevExpress.XtraVerticalGrid.Events;

private void propertyGridControl1_FocusedRowChanged(object sender, 
FocusedRowChangedEventArgs e) {
    PropertyGridControl pg = sender as PropertyGridControl;
    // Do not display anything when a category row is selected.
    if (e.Row is CategoryRow) {
        labelName.Text = "";
        labelDescription.Text = "";
        return;
    }
    // Will store the object which owns the current property.
    object targetObject;
    // Retrieve information on the current property.
    PropertyDescriptor propDescriptor = pg.GetPropertyDescriptor(e.Row, out targetObject);
    labelName.Text = propDescriptor.Name + ", belongs to the " + 
      targetObject.GetType().ToString() + " class";
    labelDescription.Text = propDescriptor.Description;            
}
See Also