Xceed Grid for WinForms v4.3 Documentation
What is a row?

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Grid elements > What is a row?

A row is a horizontal area in the grid that can contain cells, display information such as labels or manage other rows in the grid. A row that contains cells is represented by the CellRow class while a row that does not contain cells is represented by the Row class. 

Cell rows

Every row that contains cells will contain a cell for each column in the grid. Each of these cells will always have the same index, name and width as its parent column. 

There are various specializations of the CellRow class: the DataRow class which represents a row that is bound to a data source or user provided data, the ValueRow class which contains a cell for each column in the grid but is not bound to a data source, the InsertionRow class which contains a cell for each column in the grid and is used by the end-user to insert new DataRow objects into the grid, he ColumnManagerRow class which represents a row that is used to manage the columns in the grid, and the SummaryRow class which represents a row used to display the results of statistical functions (running sums).

Cell-less rows

Rows that do not contain cells can be used to display labels or manage other rows in the grid. Xceed Grid for WinForms provides various cell-less row classes: the TextRow class which is used to display text, the GroupManagerRow class which is used to manage groups, the GroupByRow class which represents a row in which ColumnManagerCell objects can be drag and dropped in order to group a grid's data rows, and the SpacerRow class which represents a row that is used to provide spacing between rows and detail grids in the grid.  All of these rows derive from the Row class. 

Accessing rows

The grid and each group in the grid have various collections of rows that can be accessed via their corresponding properties. The GridControl class (which represents the grid) exposes the DataRows property which allows you to access all the data rows of the grid regardless of group hierarchy and the GetSortedDataRows method which allows you to access the data rows in the order in which they are sorted and grouped. It also exposes the FixedHeaderRows and FixedFooterRows properties which allow you to access the rows in the fixed header and footer sections of the grid. The rows found in the scrollable header and footer sections of the grid can be accessed via the HeaderRows and FooterRows properties (see Example 1).

The Group class (which represents a group) also exposes the GetSortedDataRows method to access its data rows. Setting the GetSortedDataRows recursive parameter to false, will return only the data rows directly contained in the group. If a group is not the last-level group, then no data rows will be returned. Setting recursive to true, will return all child data rows of the group, including the data rows found in child groups (see Example 2). The Group class also exposes the HeaderRows and FooterRows properties to access the header and footer rows of a group (see Example 3).

Things you should consider

Examples

Example 1: Accessing rows

VB.NET
Copy Code
GridControl1.DataRows( 42 ).BackColor = Color.BlueViolet
GridControl1.FixedFooterRows( 0 ).HorizontalAlignment = HorizontalAlignment.Left
GridControl1.FixedHeaderRows( 1 ).Height = 20 ' pixels
GridControl1.FooterRows( 0 ).ForeColor = Color.LightBlue
GridControl1.HeaderRows( 0 ).ReadOnly = True
C#
Copy Code
gridControl1.DataRows[ 42 ].BackColor = Color.BlueViolet;
gridControl1.FixedFooterRows[ 0 ].HorizontalAlignment = HorizontalAlignment.Left;
gridControl1.FixedHeaderRows[ 1 ].Height = 20; //pixels
gridControl1.FooterRows[ 0 ].ForeColor = Color.LightBlue;
gridControl1.HeaderRows[ 0 ].ReadOnly = true;

Example 2: Retrieving data rows

VB.NET
Copy Code
' Change the color of the immediate child data rows of group to pink.
' Any data rows in child groups will NOT be affected.
' If the group is not a last-level group (does not contain data rows )
' nothing will happen.
Dim row As Row
For Each row In group.GetSortedDataRows( False )
   row.BackColor = Color.Pink
Next row
' Change the height of ALL the data rows in the group, including the
' data rows found in child groups to 20 pixels.
For Each row in group.GetSortedDataRows( True )
   row.Height = 20; 'pixels
Next row
C#
Copy Code
// Change the color of the immediate child data rows of group to pink.
// Any data rows in child groups will NOT be affected.
// If the group is not a last-level group (does not contain data rows )
// nothing will happen.
foreach( Row row in group.GetSortedDataRows( false ) )
{
   row.BackColor = Color.Pink;
}
// Change the height of ALL the data rows in the group, including the
// data rows found in child groups to 20 pixels.
foreach( Row row in group.GetSortedDataRows( true ) )
{
   row.Height = 20; //pixels
}

Example 3: Accessing group headers and footers

VB.NET
Copy Code
group.HeaderRows( 0 ).Alignment = ContentAlignment.MiddleRight
group.FootRows( 0 ).Height = 20 'pixels
C#
Copy Code
group.HeaderRows[ 0 ].Alignment = ContentAlignment.MiddleRight;
group.FooterRows[ 0 ].Height = 20; //pixels