Cell
Cell(iRow, iCol)
Used with other grid properties to change the properties of individual cells, rows and columns
iRow | Integer | Row position |
---|---|---|
iCol | Integer | Column position |
Returns result of type OBJECT or SYM
Applies to: Grid
Introduced in KCML version 5.02
Cell
Used with other grid properties to change the properties of individual cells, rows and columns
Runtime-only Integer property
Applies to: Grid
The Cell method is used to get an object reference to a particular cell on the grid. The method moves the programming cell (not the cursor) to the specified cell or range of cells and the now deprecated Cell property will operate on that cell or cells. Normally if properties are set without the Cell method then the whole grid is operated on. For example, the following would change the row height for every row in the grid:
.GridControl1.RowHeight = 120
To change the properties of an individual cell, row or column, you must specify the Cell() method followed by the row and column of the cell(s) that you wish to reference. Once the cell position has been set, subsequent property changes for the cell(s) need only specify the Cell subproperty. For example, the following would move the programming cell to row 4, column 5 and place some text into the cell. It will also set the background color of the cell to DarkBlue:
.GridControl1.Cell(4,5).Text$ = "A very warm summers day!" .GridControl1.Cell.BackColor = &.DarkBlue ...
This can simplified by using OBJECT notation thus
OBJECT c = .GridControl1.Cell(4,5) c.Text$ = "A very warm summers day!" c.BackColor = &.DarkBlue ...
OBJECT notation is preferred over the use of the Cell property.
Setting the row or column values to zero will force subsequent property changes to work on all cells in the specified row or column, for example the following would set the background color of all cells in column 5 to DarkBlue and the text color to White:
OBJECT c = .gridControl1.Cell(0, 5) c.BackColor = &.DarkBlue c.TextColor = &.White ...
Note that if both the row and column values are set to zero then subsequent property changes will operate on the entire grid, for example:
OBJECT c = .gridControl1.Cell(0, 0) c.BackColor = &.DarkBlue c.TextColor = &.White ...
The cell selected this way is nothing to do with the cursor or user input focus rectangle.
Be aware that KCML instantiates only one cell at a time in the server event handling code and as a consequence the following code will not work as you might expect.
Grid.Cell(x1,y1).Text$=Grid.Cell(x2,y2).Text$
Instead it will have to be expressed as
a$=Grid.Cell(x1,y1).Text$ Grid.Cell(x2,y2).Text$=a$
Effectively you cannot use a Cell() method more than once in the same statement.