ComponentOne True DBGrid Pro 8
Close Method

 

Close Method

The Close method disconnects the grid from the data source.

Syntax

TDBGrid.Close [repaint]

Arguments

repaint is an optional Boolean that determines whether the grid should clear its display.

Return Value

None

Remarks

The optional repaint argument instructs the grid whether or not to "clear" the grid of data. If repaint is True (the default if not specified), the grid is cleared of all data; if repaint is False, the data currently on display at the time of the close remains, but the grid's user interface is disabled so that no operations can be performed on the grid. All database related coding operations (such as MoveNext, MovePrevious) will return data access errors until the connection is re-established with any of the following methods: ReBind, Refresh, or ReOpen.

Passing a value of False to the Close method is useful when operations are performed that would otherwise "flicker" the display.

The data source connection is automatically reopened whenever the grid's ReBind, Refresh. or ReOpen methods are executed. The grid will be repopulated with data and the appropriate row will be made current. Care should be taken when using ReBind or ReOpen with unbound grids, as these operations assume the current row bookmark still exists.

In the case of a bound grid, Close allows database operations to be performed without interference from the grid. For example, closing the grid and closing the Recordset and Database objects associated with the Data control:

TDBGrid1.Close

Data1.Recordset.Close

Data1.Database.Close

would allow database operations which manipulate the database files (such as pack or copy) to be performed.

The Close method can also be used to temporarily disconnect a grid from its data source when many notification-generating operations need to be performed. For example, if your application contains a loop that deletes all of the selected records in a grid, you can first Close (disconnect) the grid as follows:

TDBGrid1.Close False

so that no notifications will be processed by the grid. Otherwise, the grid will show every row movement and deletion as the records are deleted. The False argument tells the grid not to repaint the screen, which has the effect of leaving the grid display unchanged. When the record delete operations are completed, perform a grid ReOpen (or ReBind) to reconnect and repaint the grid with the remaining (undeleted) records. This technique is also useful for RDC/RDO where clones are not available.

See Also

TDBGrid Control

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback