Skip to content

TStyledDbNavigator - Technical Reference

Overview

TStyledDbNavigator is a styled database navigator component that replaces the standard TDBNavigator with modern styled buttons and enhanced visual features.

Class Hierarchy

TWinControl
  └─ TCustomPanel
      └─ TStyledDbNavigator

Unit

pascal
Vcl.StyledDbNavigator

Description

TStyledDbNavigator provides all functionality of TDBNavigator while offering modern styling, better icons (especially for vertical orientation), optional button captions, and full customization of button appearance.

Each navigation button is a TStyledNavButton with complete styling control.

Key Features

  • All TDBNavigator functionality: First, Prior, Next, Last, Insert, Delete, Edit, Post, Cancel, Refresh
  • Styled buttons: Full StyleFamily/Class/Appearance support
  • Optional captions: Show/hide button captions
  • Better vertical icons: Improved up/down arrow icons for vertical layout
  • Custom ImageList support: Use your own icons
  • Per-button styling: Each button can have its own style
  • Orientation: Horizontal or vertical layout
  • Hints and captions: Customizable for each button

Main Properties

Database Properties

PropertyTypeDescription
DataSourceTDataSourceData source to navigate
VisibleButtonsTButtonSetWhich buttons to show ([nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbDelete, nbEdit, nbPost, nbCancel, nbRefresh])
ConfirmDeleteBooleanShow confirmation before deleting (default: True)

Layout Properties

PropertyTypeDescription
OrientationTNavigatorOrientationHorizontal or vertical button layout (nboHorizontal, nboVertical)
ShowCaptionsBooleanShow button captions (default: False)
ShowHintsBooleanShow button hints
KindTDBNavigatorKindNavigator kind (dbnHorizontal, dbnVertical) - sets Orientation

Styling Properties

PropertyTypeDescription
StyleFamilyTStyledButtonFamilyStyle family for all buttons
StyleClassTStyledButtonClassStyle class for all buttons
StyleAppearanceTStyledButtonAppearanceAppearance for all buttons
StyleDrawTypeTStyledButtonDrawTypeButton shape
StyleRadiusIntegerCorner radius
FlatBooleanFlat button appearance

Images

PropertyTypeDescription
ImagesTCustomImageListCustom ImageList for button icons
ImageWidthIntegerWidth of images
ImageHeightIntegerHeight of images

Button Properties

PropertyTypeDescription
Buttons[Index]TStyledNavButtonAccess to individual navigation buttons (read-only)
ButtonWidthIntegerWidth of buttons (0 = auto)
ButtonHeightIntegerHeight of buttons (0 = auto)

The navigator contains these standard buttons:

ButtonPurposeDefault Caption
nbFirstGo to first recordFirst
nbPriorGo to previous recordPrior
nbNextGo to next recordNext
nbLastGo to last recordLast
nbInsertInsert new recordInsert
nbDeleteDelete current recordDelete
nbEditEdit current recordEdit
nbPostPost changesPost
nbCancelCancel changesCancel
nbRefreshRefresh datasetRefresh

Events

EventDescription
OnClickButton clicked - parameter indicates which button
BeforeActionBefore navigation action - can be canceled
OnEnableNavBtnEnable/disable specific buttons dynamically

Usage Examples

Basic DbNavigator

pascal
var
  Nav: TStyledDbNavigator;
begin
  Nav := TStyledDbNavigator.CreateStyled(Self,
    BOOTSTRAP_FAMILY,
    btn_primary,
    BOOTSTRAP_NORMAL);
  Nav.Parent := Self;
  Nav.DataSource := DataSource1;
  Nav.Align := alBottom;
end;

DbNavigator with Captions

pascal
Nav := TStyledDbNavigator.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Nav.Parent := Self;
Nav.DataSource := DataSource1;
Nav.ShowCaptions := True;
Nav.ButtonWidth := 80;
Nav.StyleDrawType := btRounded;

Vertical DbNavigator

pascal
Nav := TStyledDbNavigator.CreateStyled(Self,
  ANGULAR_LIGHT_FAMILY,
  acl_primary,
  ANGULAR_RAISED);
Nav.Parent := Self;
Nav.DataSource := DataSource1;
Nav.Align := alLeft;
Nav.Orientation := nboVertical;  // or Kind := dbnVertical
Nav.Width := 40;
pascal
Nav := TStyledDbNavigator.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Nav.DataSource := DataSource1;
Nav.VisibleButtons := [nbFirst, nbPrior, nbNext, nbLast, nbRefresh];  // Hide edit buttons
Nav.ShowCaptions := True;
pascal
Nav := TStyledDbNavigator.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Nav.DataSource := DataSource1;
Nav.Images := MyNavigatorImageList;
// Assign custom images to buttons
// Image indices: 0=First, 1=Prior, 2=Next, 3=Last, 4=Insert,
//               5=Delete, 6=Edit, 7=Post, 8=Cancel, 9=Refresh

Customizing Individual Buttons

pascal
Nav := TStyledDbNavigator.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Nav.DataSource := DataSource1;

// Customize Delete button to be red
Nav.Buttons[nbDelete].StyleClass := btn_danger;
Nav.Buttons[nbDelete].Hint := 'Delete this record';

// Customize Post button to be green
Nav.Buttons[nbPost].StyleClass := btn_success;
Nav.Buttons[nbPost].Caption := 'Save';

Handling OnClick Event

pascal
procedure TForm1.Navigator1Click(Sender: TObject; Button: TNavigateBtn);
begin
  case Button of
    nbInsert: ShowMessage('Inserting new record');
    nbDelete: ShowMessage('Deleting record');
    nbPost: ShowMessage('Saving changes');
  end;
end;

Disabling Confirm Delete

pascal
Nav := TStyledDbNavigator.Create(Self);
Nav.DataSource := DataSource1;
Nav.ConfirmDelete := False;  // Delete without confirmation

Main Methods

RegisterDefaultRenderingStyle (Class Method)

Sets the default rendering style for all TStyledDbNavigator instances.

pascal
class procedure RegisterDefaultRenderingStyle(
  const ADrawType: TStyledButtonDrawType;
  const AFamily: TStyledButtonFamily = DEFAULT_CLASSIC_FAMILY;
  const AClass: TStyledButtonClass = DEFAULT_WINDOWS_CLASS;
  const AAppearance: TStyledButtonAppearance = DEFAULT_APPEARANCE;
  const AStyleRadius: Integer = DEFAULT_RADIUS); virtual;

BtnClick

Programmatically clicks a navigation button.

pascal
procedure BtnClick(Index: TNavigateBtn); virtual;

Important Notes

  • DataSource Required: Must be connected to a TDataSource
  • Button Auto-Enable: Buttons automatically enable/disable based on dataset state
  • Vertical Icons: Improved icons for vertical orientation (up/down arrows)
  • Custom Captions: All button captions and hints can be customized
  • DPI Aware: Automatically scales with DPI changes

See Also

Released under Apache License, Version 2.0.