1. Home
  2. Computing & Technology
  3. Delphi Programming

How to Enable the Refresh button on a DBNavigator for ReadOnly Datasets

By , About.com Guide

When using the TDBNavigator component with read-only datasets, the Refresh button is disabled by design. In many situations you will have a read-only dataset displayed in a DBGrid, connected to a DBNavigator where DataSet's (TxxxTable or TxxxQuery) Refresh method is expected and "legal".

Here's how to re-enable the DBNavigator's Refresh button:

  1. Expose the Buttons property of the DBNavigator by using the protected hack method. First we create a class to access the protected members of a DBNavigator:

    TDBNavigatorEx = class(TDBNavigator) ;

  2. Set Enable = true for the Refresh button inside the dataset's OnOpen event handler.

    TDBNavigatorEx(DBNavigator).Buttons[nbRefresh].Enabled := TRUE ;

    Note: "DBNavigator" is the name of the DBNavigator component attached to a readonly datasource/dataset.

That's it. Now you can use the Refresh button even on a readonly dataset.

Delphi tips navigator:
» Implementing custom sorting for a TListView component
« Placing a Form inside a TabSheet of a TPageControl

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2005 Delphi Tips
  7. How to Enable the Refresh button on a DBNavigator for ReadOnly Datasets

©2009 About.com, a part of The New York Times Company.

All rights reserved.