Recent

Author Topic: TDBNavigator - Taborder  (Read 1280 times)

Int3g3r

  • New Member
  • *
  • Posts: 17
TDBNavigator - Taborder
« on: May 14, 2024, 10:57:45 am »
Hello

How can I change the tab order on the buttons in the TDBNavigator component?
Is it possible to deactivate the tab stop for individual buttons?

Does anyone have an example?

Greetings Int3g3r

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: TDBNavigator - Taborder
« Reply #1 on: May 14, 2024, 01:47:08 pm »
No, you cannot do that. You might try to study the code and subclass it, but the possibility of success is not high.

Int3g3r

  • New Member
  • *
  • Posts: 17
Re: TDBNavigator - Taborder
« Reply #2 on: May 14, 2024, 03:29:01 pm »
No, you cannot do that. You might try to study the code and subclass it, but the possibility of success is not high.

OK Thank you.

wp

  • Hero Member
  • *****
  • Posts: 12530
Re: TDBNavigator - Taborder
« Reply #3 on: May 14, 2024, 04:25:25 pm »
Create your own DBNavigator to have full controls over the order and type of buttons. Using DatabaseActions this is quite easy and requires no code:
  • Drop a TImageList on the form; add the button icons that you need for your navigator buttons.
  • Drop a TPanel on the form
  • Select the TPanel and go to its ChildSizing property: Set ControlsPerLine to a value equal to or larger than the button count that you need. Set. EnlargeHorizontal and EnlargeVertical to crsAnchorAligning and Layout to cclLeftToRightThenTopToBottom.
  • Add as many TSpeedButtons to the panel as you need. Due to the Childsizing they are automatically arranged to tightly fill the bounds of the panel. If you need additional spacing between the buttons, adjust the button's ChildSizing.HorizontalSpacing.
  • Add a TActionList to the form
  • Assign the imagelist to Images property of the ActionList.
  • Double-click the ActionList. In the appearing ActionList editor, click on the down-arrow next to "+" and select "New Standard Acticon". Scroll down a bit until you see the "Database" node. Select the action that you need, for example "TDatasetPost" for the action to post a dataset. With the new action selected go to the object inspector and change the ImageIndex to the that of the required icon, and specify the linked dataset in the Dataset property.
  • In the designer (or object tree) select the speedbutton which you want to use for posting. Go to its "Action" property and select the corresponding action from the list. Delete the Caption of the speedbutton.
  • Repeat with the other buttons: create the corresponding action and assign it to the button
  • If you later want to rearrange the order of the buttons, you select the button to be moved, right-click and pick one of the "Z-Order" commands. "Move to back" means: move the button to the very left, "Back one" moves is to the left by one position;"Move to Front"/"Forward one" do the same, but in the other direction.
  • That's all. The database functionality is built into the actions.

Int3g3r

  • New Member
  • *
  • Posts: 17
Re: TDBNavigator - Taborder
« Reply #4 on: May 15, 2024, 11:54:20 am »
Create your own DBNavigator to have full controls over the order and type of buttons. Using DatabaseActions this is quite easy and requires no code:

Thank you thats great!

Where can i set a confirmation dialog?
For delete for example?

Follow code doesn't work.
The delete doesnt get executet after confirmation.
Code: Pascal  [Select][+][-]
  1. procedure TformMain.DataSetDelete1Execute(Sender: TObject);
  2. begin
  3.      if MessageDlg('Eintrag löschen?',mtConfirmation,[mbCancel,mbOK],0) = mrCancel then
  4.   begin
  5.     Abort;
  6.   end;
  7. end;  

wp

  • Hero Member
  • *****
  • Posts: 12530
Re: TDBNavigator - Taborder
« Reply #5 on: May 15, 2024, 04:07:09 pm »
You do not call the inherited method. And I'd invert the logic because I am not sure which ModalResult is returned when the dialog is closed by the 'x' button in the title bar (is it mrCancel? or is it mrClose?):
Code: Pascal  [Select][+][-]
  1. procedure TformMain.DataSetDelete1Execute(Sender: TObject);
  2. begin
  3.   if MessageDlg('Eintrag löschen?',mtConfirmation,[mrCancel,mbOK],0) = mrOK  then
  4.     inherited
  5.   else
  6.     Abort;
  7. end;

Another possibility would be to use a standard action in place of the DatabaseAction and code the deletion manually:
Code: Pascal  [Select][+][-]
  1. TFormMain.DeleteActionExecute(Sender: TObject);  // TDeleteAction is a standard action with manually set Caption='Delete', Hint='Delete record' and with this OnExecute handler.
  2. begin
  3.   if MessageDlg('Eintrag löschen?', mtConfirmation, [mbOK, mbCancel], 0) = mrOK then
  4.     MyDataset.Delete;
  5. end;
  6.  
  7. // Disables the button when deletion is not possible.
  8. procedure TMainForm.DeleteAction(Sender: TObject);
  9. begin
  10.   DeleteAction.Enabled := MyDataset.Active and MyDataset.CanModify and not (MyDataset.BOF and MyDataset.EOF);
  11. end;

 

TinyPortal © 2005-2018