The ColCount property returns an array containing the number of identified cells in each grid row.
Not available at design-time. Read-only at run-time.
object.ColCount(rowIndex) = [integer]
Where object is an object expression that evaluates to one of the controls in the Applies To list, row in and integer is the index of the currently active tab page.
The ColCounts collection was introduced from version 11.0 onwards as an easier way of working with the ColCount property. Either syntax can be used to return the number of cells in a grid row. The ColCounts collection may be easier to work with if you are looping through all the rows of a grid as the collection contains a count property, which returns the number of rows the grid contains.
The ColCount property is intended for use 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 ColCount property (or ColCounts collection) is 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.
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 RowCount = App.ActiveForm.myGrid.RowCount;
//loop through each row
for (var currentRow = 0; currentRow < RowCount; currentRow++){
//obtain the number of cells in the current row
var ColumnCount = App.ActiveForm.myGrid.ColCount(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 = App.Activeform.myGrid.Cells(currentRow, currentColumn);
if (currentCell.Text == "OVERDUE"){
currentCell.ForeColor = "Red";
}
}
}
ColCounts collection | Cell property | ColIndex property | RowIndex property | HeadRows property | Marker property
© 2004-2021 looksoftware. All rights reserved.