Recent

Author Topic: How do you add a row after last row in DBGrid with DBNavigator?  (Read 6764 times)

paulkp

  • New Member
  • *
  • Posts: 13
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?

LacaK

  • Hero Member
  • *****
  • Posts: 605
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #1 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)

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #2 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.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

paulkp

  • New Member
  • *
  • Posts: 13
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #3 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 . .

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #4 on: March 03, 2014, 01:25:08 pm »
I didn't say + I said Next
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

paulkp

  • New Member
  • *
  • Posts: 13
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #5 on: March 03, 2014, 02:45:52 pm »
Same prob with Next.

I'm getting used to arrowing down to add a record . .

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #6 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.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

paulkp

  • New Member
  • *
  • Posts: 13
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #7 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)

apexcol

  • Jr. Member
  • **
  • Posts: 54
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #8 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.  

wp

  • Hero Member
  • *****
  • Posts: 7756
Re: How do you add a row after last row in DBGrid with DBNavigator?
« Reply #9 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

 

TinyPortal © 2005-2018