Board index » delphi » Want Navigator Insert button to append instead of insert

Want Navigator Insert button to append instead of insert

I didn't know whether to put this post in vcl or database sql server, so I
put it in both.

I am using a stored procedure to load data from sql server into a dbgrid.
When the user clicks the + button on the navigator bar, I want to append a
record to the end of the grid, not insert it where the cursor is at.

I have tried using before insert to set the dataset to the last record.
What happened with that was the record was inserted above the last record.

Any ideas?

Thanks!
Deb

 

Re:Want Navigator Insert button to append instead of insert


Hi,

I think you should take a look at the BeforeAction event of the
TDBNavigator.  In there you could specify your custom action for a button
and then abort the default action.

So in the BeforeAction event of the TQuery use the folowing code :

if button = nbInsert then { The Insert Button has been pressed }
begin
  Sender.Datasource.Dataset.Append;  { You want to append }
  Abort;                                                { Since we want to
use the Append, we should abort the default which is Insert }
end;

--
Stefaan Lesage

ECA nv
Database Administrator
Programmer

E-Mail : Stefaan.Les...@eca.be

Quote
Debra Paulsen <debra.paul...@10hz.com> wrote in message

news:7j6qb3$ltp6@forums.borland.com...
Quote
> I didn't know whether to put this post in vcl or database sql server, so I
> put it in both.

> I am using a stored procedure to load data from sql server into a dbgrid.
> When the user clicks the + button on the navigator bar, I want to append a
> record to the end of the grid, not insert it where the cursor is at.

> I have tried using before insert to set the dataset to the last record.
> What happened with that was the record was inserted above the last record.

> Any ideas?

> Thanks!
> Deb

Other Threads