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

How to cancel the TDBNavigator button click

By , About.com Guide

If you need to cancel the action raised by a click on one of DBNavigator buttons, you need to Abort the action in the BeforeAction event.

In Delphi database applications, where the TDBnavigator is used to edit and navigate through the dataset, if you need to cancel the click on a particular button, use the next code (handle the BeforeAction event, by calling Abort for a particular button):

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TDBForm.DBNavigatorBeforeAction(Sender: TObject;
   Button: TNavigateBtn) ;
begin
   if (Button = nbRefresh) then
   begin
     SysUtils.Abort; //cancel the refresh action
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Note: The Abort procedure from the SysUtils unit raises a so-called "silent exception" (EAbort), which does not display an error message to the user.

Delphi tips navigator:
» Fixing the "Transaction ... an object is in a zombie state" error in Delphi ADO database applications
« Fixing the CheckBoxList ASP.NET Web Server control - adding Attributes to Items

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 cancel the TDBNavigator button click

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

All rights reserved.