ColCounts Collection

A collection of ColCount properties for each row of a grid.

App.ActiveForm.DataGridControl.ColCounts(rowIndex)

Client support

   Newlook Smartclient only.

Version Support

Introduced for the DataGrid control in version 11.0.0.

Use

The ColCounts collection is intended to be used with grids in non-column mode (grids where the ShowColumns property is False).

When a grid is in column mode (ShowColumns is True), the recognition engine will organize the grid contents into columns, creating additional cells in some rows if needed, and every row of the grid will contain the same number of cells. The number of columns in each row can be returned by <datagridControl>.Columns.Count.

When columns are not enabled in a grid however, it is possible for different rows of the grid to contain differing numbers of cells. For example, a non-column grid may contain 4 cells in its header row, 7 cells of data in the first row, and only 2 cells of data in the second. In this scenario, the ColCounts collection can be used to determine the number of cells in each row. This is particularly relevant if you are running logic which loops through all the cells in your grid.

EXAMPLE

The following JScript example loops through all the cells in a non-column grid and sets the forecolor of any cell containing the text "OVERDUE" to red:

//obtain maximum row count for the grid

var Grid = App.ActiveForm.myGrid;

var RowCount = Grid.ColCounts.Count;

 

//loop through each row

for (var currentRow = 0; currentRow < RowCount; currentRow++){

//obtain the number of cells in the current row

var ColumnCount = Grid.ColCounts(currentRow);

 

    //loop through each cell in the current row and highlight and cells with the text "OVERDUE"

for (var currentColumn = 0; currentColumn < ColumnCount; currentColumn++){

    var currentCell = Grid.Cells(currentRow, currentColumn);

    if (currentCell.Text == "OVERDUE"){

        currentCell.ForeColor = "Red";

    }

}

}

Applies To

DataGrid control

See Also

Columns collection | ColCount property | Count property | Cell property | ColIndex property | RowIndex property | HeadRows property


© 2004-2021 looksoftware. All rights reserved.