VGridRows.Item[String] Property
Gets a row from the rows collection by its name.
Namespace: DevExpress.XtraVerticalGrid.Rows
Assembly: DevExpress.XtraVerticalGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
Declaration
Parameters
Name | Type | Description |
---|---|---|
nameOrFieldName | String | A string value specifying the name of the desired row. |
Property Value
Type | Description |
---|---|
BaseRow | A BaseRow object representing a row with the required name. null (Nothing in Visual Basic) if there are no rows with the specified name in the collection. |
Remarks
Use this property to obtain a row object by its name from the rows collection. When searching the parameter value is compared with the BaseRow.Name property of row objects. If no matches are found, null (Nothing in Visual Basic) is returned.
The Item property of the VGridControlBase.Rows collection searches for the row with the specified name throughout the entire collection of grid rows including children of all parent rows, if any. This property gives the ability to access a specific row within the entire rows collection by using the following syntax:
vGridControl1.Rows[name].
Example
The following example creates a row object of the EditorRow type that will contain the middle initials of employees. The VGridRows.Insert method is used to insert the row prior to a row containing last names. The required position is obtained by using the VGridRows.IndexOf method, which is passed with a row object specified by its name.
Note that if a row containing last names does not exist (or is specified by the wrong name), the rowLN variable contains null (Nothing in Visual Basic). In this case, the VGridRows.IndexOf method returns -1 and the new row (rowMI) is inserted at the beginning of the collection.
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
private void InsertRow() {
// creaing a new row bound to a specific field and specifying its caption
EditorRow rowMI = new EditorRow("middle_initial");
rowMI.Properties.Caption = "Middle Initial";
// obtaining a row object containing last names specifying its name
BaseRow rowLN = vGridControl1.Rows["LastName"];
// inserting the row before a row containing last names
vGridControl1.Rows.Insert(rowMI, vGridControl1.Rows.IndexOf(rowLN));
}