Storage Mode > Interactions between True DBGrid and XArrayDB > Inserting and removing XArrayDB columns |
The InsertColumns and DeleteColumns methods are analogous to InsertRows and DeleteRows. Both methods require a column index argument and accept an optional second argument that defaults to 1.
When you insert or delete XArrayDB columns, the grid will not automatically insert or delete its own columns. You must write code to do this, as in the following example, which implements a command button that inserts a new column before the current one:
Example Title |
Copy Code
|
---|---|
Private Sub Command1_Click() Dim C As TrueDBGrid80.Column With TDBGrid1 MyArray.InsertColumns .Col Set C = .Columns.Add(.Col) C.Visible = True .ReBind .SetFocus End With End Sub |
Note the use of the grid's ReBind method rather than the Refresh method. This is necessary because the addition or deletion of a column constitutes a change in the underlying database structure as opposed to a change in data values.