|
|
Add-Delete Columns and Rows, Access to Objects
| Methods: |
AddRow, AddCol, RemoveCol, RemoveRow, ClearAll, ClearRows, ColExists |
| Properties: |
Rows, Cols, Column, Row, Cell |
Adding/Removing columns and rows
We need to add one or more columns before adding rows:
grid.Cols = 4
' or this way:
For I = 1 To 4 grid.AddCol "", 30 Next
|
|
Now we can add several rows:
grid.Rows = 4
' or this way:
For I = 1 To 4 grid.AddRow Next
|
|
Number of columns and rows
To obtain the number of columns we use the Cols property and to get the number of rows we use the Rows property:
MsgBox grid.Cols MsgBox grid.Rows
|
| |
Access the internal objects of the grid - the Column object, the Row object, the Cell object
Let us get references to the first column, first row and first cell:
Dim col, row, cell
Set col = grid.Column(0) Set row = grid.Row(0) Set cell = grid.Cell(0,0)
|
| |
We can get a reference to the Column object by its title as well:
Set col = grid.Column("A") Set cell = grid.Cell("A",0)
|
| |
Check that the column exists
Check that the column with specified title already exists, before adding a new column:
If grid.ColExists("A") Then MsgBox "Column A exists." End If
|
| |
Removing columns and rows
Removing columns and rows is simple:
grid.RemoveCol(0)
' or
grid.RemoveCol("A")
grid.RemoveRow(0)
|
| |
Removing all rows at once
We can remove all rows using a single function call:
Resetting the Grid object
Remove all objects and data at once:
|