Previous Topic

Next Topic

Inhoudsopgave

Book Index

TDBNavigator Control

TDBNavigator

Description

TDBNavigator (the database navigator) is used to move through the data in a dataset and perform operations on the data, such as inserting a blank record or posting a record.

Remarks

Use the database navigator on forms that contain data-aware controls, such as TDBGrid or TDBEdit. TDBNavigator lets the user control the dataset when editing or viewing the data.

When the user chooses one of the navigator buttons, the appropriate action occurs on the dataset to which the navigator is linked. For example, if the user clicks the Insert button, a blank record is inserted in the dataset.

TDBNavigator can show any or all of the following buttons:

Button

Purpose

First

Sets the current record to the first record in the dataset, disables the First and Prior buttons, and enables the Next and last buttons if they are disabled.

Prior

Sets the current record to the previous record and enables the Last and Next buttons if they are disabled.

Next

Sets the current record to the next record and enables the First and Prior buttons if they are disabled.

Last

Sets the current record to the last record in the dataset, disables the Last and Next buttons, and enables the First and Prior buttons if they are disabled.

Insert

Inserts a new record before the current record, and sets the dataset into Insert and Edit mode.

Delete

Deletes the current record and makes the next record the current record.

Edit

Puts the dataset into Edit mode so that the current record can be modified.

Post

Writes changes in the current record to the database.

Cancel

Cancels edits to the current record, restores the record display to its condition prior to editing, and turns off Insert and Edit mode if they are active.

Refresh

Refreshes the buffered data in the associated dataset.

TDBNavigator Properties

Property Property ComfirmDelete: Boolean (R/W)

Determines whether a message box appears asking the user to confirm record deletions initiated using the database navigator. Use the ConfirmDelete property to help prevent the user from accidentally deleting a record from the dataset. If ConfirmDelete is true, a message box appears when the user presses the delete button and the record isn't deleted unless the user chooses the OK button. If ConfirmDelete is false, no message box appears and the record is simply deleted.

Property Property Flat: Boolean (R/W)

Determines whether the buttons of the navigator have a three-dimensional (3-D) look with borders or two-dimensional look without borders. When Flat is true, the navigator buttons appear flat and do not have borders separating them. When Flat is false, the buttons are clearly defined.

Property Property Hints: TStringList object (R)

Provides a way to customize the Help Hints for the buttons on the database navigator.

Use the Hints property to supply Help Hints of your choosing for the individual navigator buttons. Each button has a default Help Hint. Hints allow the values of any or all of these default Help Hints to be replaced by customized hints. Hints is a string list. Each hint is a string. The first string in the string list becomes the Help Hint for the first button on the navigator (the First button). The seventh hint becomes the Help Hint for the seventh button (the Edit button). When specifying Hints at runtime, enter an empty string for any Help Hint that should keep the default value. Simply leave the line blank when using the string list property editor of the Object Inspector for the Hints property.

Note: To have the Help Hints appear at runtime, set the ShowHint property to true.

Property Property VisibleButtons: Set (R/W)

Determines which buttons appear on the database navigator. Use VisibleButtons to select the buttons that will appear on the navigator. Leave any of the navigator buttons out of the VisibleButtons set to hide those buttons and thereby prevent the user from performing certain operations. For example, to only allow the user to view the records in the dataset, VisibleButtons should include only the nbFirst, nbPrior, nbNext, and nbLast.

General Data-Aware Control Properties

Property Property DataField: String (R/W)

Property Property DataSource: TDataSource (R/W)

Property Property ReadOnly: Boolean (R/W)