PropertyGridControl.GetPropertyDescriptor(BaseRow, out Object) Method
Returns the property descriptor which is associated with the specified row. The object which owns the property is returned via the targetObject parameter.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
Declaration
Parameters
Name | Type | Description |
---|---|---|
row | BaseRow | A BaseRow object which is bound to the required property. |
targetObject | Object | Returns the object which contains the required property, or an array of objects which own the property (when the PropertyGridControl is bound to multiple objects via the PropertyGridControl.SelectedObjects member). |
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:
The button’s FlatAppearance.BorderColor property is selected:
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;
}