Board index » delphi » Tying in DBNavigator to Menu items

Tying in DBNavigator to Menu items

I have a dbNavigator control on my form.  I also have a menu
with menu items like "Add New" or "Edit".  I want to tie
the menu items to the appropriate function provided by
the dbNavigator.

I cannot seem to find the information I need on how to
make the dbNavigator work inside a menu item procedure.
How can I do this?

Thanks

Matt
--
raff...@netcom.com
Web Page  ftp://ftp.netcom.com/ra/raffelm/isdhome.html
          ftp://ftp.netcom.com/ra/raffelm/homeofmatt.html

 

Re:Tying in DBNavigator to Menu items


Quote
raff...@netcom.com (Matt Raffel) wrote:
> I have a dbNavigator control on my form.  I also have a menu
> with menu items like "Add New" or "Edit".  I want to tie
> the menu items to the appropriate function provided by
> the dbNavigator.

> I cannot seem to find the information I need on how to
> make the dbNavigator work inside a menu item procedure.
> How can I do this?

Use TDBNavigator's BtnClick method in the OnClick handler for your
TMenuItem. For "Add New", that would look like:

        procedure TForm1.AddNew1Click(Sender: TObject);
        begin
                DBNavigator1.BtnClick(nbInsert);
        end;

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Re:Tying in DBNavigator to Menu items


Quote
Matt Raffel raff...@netcom.com writes:

>I have a dbNavigator control on my form.  I also have a menu
>with menu items like "Add New" or "Edit".  I want to tie
>the menu items to the appropriate function provided by
>the dbNavigator.

>I cannot seem to find the information I need on how to
>make the dbNavigator work inside a menu item procedure.
>How can I do this?

        You can assign each MenuItem.Tag an integer that corresponds to each
button thats declared as an enumerated type of TNavigateBtn. ie Your edit menu
would get a tag of 6, cancel gets a tag of 8 etc..(see TNavigateBtn in help).

        Then assign the Onclick event handler for all those MenuItem's to the
same event handler, something like -:

procedure TYourForm.MenuItemOnClick(Sender: TObject);
begin
  if Sender is TMenuItem then    
DBNavigator1.BtnClick(TNavigateBtn(TMenuItem(Sender).Tag));
end;

        This does a typecast from the tag integer to the enumerated type of
TNavigateBtn, and then presses the button.

To get the enabled property of the items in your menus, to reflect the present
status of the navigator buttons, lookup the online help for DataSource on  
OnStateChange

Other Threads