Board index » delphi » Prevend automatic insert in TDBGrid

Prevend automatic insert in TDBGrid

Hello,

When I move to the last record in a TDBGrid, and press the ArrowDown
button, a new record is inserted. I don't want this, because I have my
own procedure to insert records. I can prevend it by setting
TDBGrid.ReadOnly to true, but then I cannot edit existing records. So,
how do I prevend this automatic insertion of records? Or, as an
alternative, how can I make sure that the ArrowDown action calls my own
procedure to insert a record?

TIA,
Andr Rosendaal

 

Re:Prevend automatic insert in TDBGrid


Declare a variable in the private section of the form:

  bOkToInsert : boolean;

In the BeforeInsert event of the TTable, add:

if not bOkToInsert then
  Abort;

In your button OnClick event, add:

bOkToInsert := True;
Table1.Append;
bOkToInsert := False;

Paul / ColumbuSoft
www.columbusoft.com

Quote
Andr Rosendaal <an...@let.rug.nl> wrote in message

news:38BE6AD0.F334CC99@let.rug.nl...
Quote
> Hello,

> When I move to the last record in a TDBGrid, and press the ArrowDown
> button, a new record is inserted. I don't want this, because I have my
> own procedure to insert records. I can prevend it by setting
> TDBGrid.ReadOnly to true, but then I cannot edit existing records. So,
> how do I prevend this automatic insertion of records? Or, as an
> alternative, how can I make sure that the ArrowDown action calls my own
> procedure to insert a record?

> TIA,
> Andr Rosendaal

Re:Prevend automatic insert in TDBGrid


Paul,

Thanks. That works. I thought it could be done without setting flags -
just by setting the proper properties.

Andr

Other Threads