Lazarus

Programming => Databases => Topic started by: paulkp on March 03, 2014, 12:52:31 pm

Title: How do you add a row after last row in DBGrid with DBNavigator?
Post by: paulkp on March 03, 2014, 12:52:31 pm
Have you noticed that it doesn't SEEM possible to add a row after last row in DBGrid with DBNavigator?

But there must be some strange set of settings so that I can . . surely?
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: LacaK on March 03, 2014, 01:03:25 pm
hm, when you click "Insert" button, then dataset.Insert is called (so no Append but Insert). It is hardcoded into TDBNavigator.

You can try use BeforeAction event on TDBNavigator and call dataset.Append before TDBNavigator itself will call Insert
(but it is only hack)
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: taazz on March 03, 2014, 01:15:04 pm
pressing the last button and then the Next button should append a record if memory serves me right.
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: paulkp on March 03, 2014, 01:23:29 pm
LacaK
Thanks, Ill consider it . .

taazz
No, it doesn't. Pressing the last button and then clicking + still puts a row BEFORE the last row . .
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: taazz on March 03, 2014, 01:25:08 pm
I didn't say + I said Next
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: paulkp on March 03, 2014, 02:45:52 pm
Same prob with Next.

I'm getting used to arrowing down to add a record . .
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: taazz on March 03, 2014, 03:14:07 pm
you do know that you can create your own dbnavigator fast using an action list right? If not just drop a TActionList on the form open the list editor and on new action tool button open the drop down menu and select "new standard action" walk down the list until you encounter the database group and add all the actions on the list set the dataset of the actions drop a toolbar on the form and add as many buttons as the action link the actions to the buttons and you are ready to go. Of course now you can add the append command you miss from the db navigator, change the button images, add captions and whatever you might need. In your case I would try to create and register a new action for the append just to see how easy it is to do something along those lines.
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: paulkp on March 03, 2014, 03:16:59 pm
Thanks. I'll consider . .
(It's an in-house tool so wanted it simple but we use it a lot)
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: apexcol on December 12, 2018, 04:11:02 pm
This is a better implementation.   ;D
Only put a CheckBox on your form.

Code: Pascal  [Select][+][-]
  1. type
  2.   THackDBNav = class(TDBNavigator);
  3.  
  4. procedure TForm1.DBNavigatorAppendClick(Sender: TObject);
  5. var
  6.   DBNav: THackDBNav;
  7. begin
  8.   DBNav := THackDBNav(TControl(Sender).Parent);
  9.   if Assigned(DBNav.DataSource) and (DBNav.DataSource.State <> dsInactive) then begin
  10.     if Assigned(DBNav.BeforeAction) then
  11.       DBNav.BeforeAction(DBNav, nbInsert);
  12.  
  13.       if CheckBox1.Checked then
  14.         DBNav.DataSource.DataSet.Append
  15.       else
  16.         DBNav.DataSource.DataSet.Insert;    
  17.  
  18.         if Assigned(DBNav.OnClick) then
  19.       DBNav.OnClick(DBNav, nbInsert);
  20.   end;
  21. end;
  22.  
  23. procedure TForm1.FormCreate(Sender: TObject);
  24. begin
  25.   THackDBNav(DBNavigator1).Buttons[nbInsert].OnClick := @DBNavigatorAppendClick;
  26. end;  
  27.  
Title: Re: How do you add a row after last row in DBGrid with DBNavigator?
Post by: wp on December 12, 2018, 05:30:38 pm
Have you noticed that it doesn't SEEM possible to add a row after last row in DBGrid with DBNavigator?
Maybe the Option "dgDisableInsert" is not checked? I have a project here where the arrow down in the last row DOES add an empty row if that option is enabled.
TinyPortal © 2005-2018