Choosing Navigator Buttons to Display
Go Up to Using data controls Index
When you first place a TDBNavigator on a form at design time, all its buttons are visible. You can use the VisibleButtons property to turn off buttons you do not want to use on a form. For example, when working with a unidirectional dataset, only the First, Next, and Refresh buttons are meaningful. On a form that is intended for browsing rather than editing, you might want to disable the Edit, Insert, Delete, Post, and Cancel buttons.
The VisibleButtons property in the Object Inspector is displayed with a + sign to indicate that it can be expanded to display a Boolean value for each button on the navigator. To view and set these values, click on the + sign. The list of buttons that can be turned on or off appears in the Object Inspector below the VisibleButtons property. The + sign changes to a - (minus) sign, which you can click to collapse the list of properties.
Button visibility is indicated by the Boolean state of the button value. If a value is set to True, the button appears in the TDBNavigator. If False, the button is removed from the navigator at design time and runtime.
Note: As button values are set to False, they are removed from the TDBNavigator on the form, and the remaining buttons are expanded in width to fill the control. You can drag the control's handles to resize the buttons.
At runtime you can hide or show navigator buttons in response to user actions or application states. For example, suppose you provide a single navigator for navigating through two different datasets, one of which permits users to edit records, and the other of which is read-only. When you switch between datasets, you want to hide the navigator's Insert, Delete, Edit, Post, Cancel, and Refresh buttons for the read-only dataset, and show them for the other dataset.
For example, suppose you want to prevent edits to the OrdersTable by hiding the Insert, Delete, Edit, Post, Cancel, and Refresh buttons on the navigator, but that you also want to allow editing for the CustomersTable. The VisibleButtons property controls which buttons are displayed in the navigator. Here's one way you might code the event handler:
procedure TForm1.CustomerCompanyEnter(Sender :TObject); begin if Sender = CustomerCompany then begin DBNavigatorAll.DataSource := CustomerCompany.DataSource; DBNavigatorAll.VisibleButtons := [nbFirst,nbPrior,nbNext,nbLast]; end else begin DBNavigatorAll.DataSource := OrderNum.DataSource; DBNavigatorAll.VisibleButtons := DBNavigatorAll.VisibleButtons + [nbInsert, nbDelete,nbEdit,nbPost,nbCancel,nbRefresh]; end; end;