Skip to main content

Accessing Rows

  • 2 minutes to read

Obtaining an object that represents the desired row is the usual task when using the ExpressVerticalGrid control. This can then be used to modify the desired row’s settings or to pass the row object as a parameter to some methods.

Accessing a Specific Row

To access the desired row you can use its name or caption, which were set in the Object Inspector at design time or that have been assigned at runtime. To retrieve the desired row object use either the TcxCustomVerticalGrid.RowByName or TcxCustomVerticalGrid.RowByCaption methods. They assume that the row name or caption has a unique value since these methods find the first occurrence of the search value.

If due to some reason you can’t use the row name or caption the TcxCustomVerticalGrid.Rows or TcxCustomRow.Rows properties could be used to get the row object.

//...
//hide the Liter row
  with cxDBVerticalGrid.Rows do
   Items[fldLiter.AbsoluteIndex].Visible := False;

They can also be used in loops or if the row object is anonymous. Consider the following example:

//...
var I: Integer;
begin
  with cxDBVerticalGrid do
    begin
     for I := 0 to Rows.Count - 1 do
      begin
      if (Rows.Items[I] is TcxCategoryRow) then
         Rows.Items[I].Collapse(True);
      end;
    end;
end;

In this example all category rows are subsequently collapsed along with their sub-trees.

Other Means of Getting Rows

The ExpressVerticalGrid provides direct access to the currently focused row. Read the TcxCustomVerticalGrid.FocusedRow property to get the row object.

There are also a number of methods that allow the retrieval of row objects in both directions, relative to the specified row (it’s natural to use these methods in connection with the focused row) or for retrieving the first and last rows:

When all rows are visible these two sets of methods return the same values, as illustrated in the image below.

The next image shows the same vertical grid control where the ‘Power’ and ‘Picture’ rows are invisible (they are displayed in the Customization Form). In this case the methods will return different values.