[Lazarus] How to avoid DBGrid showing new blank record

Michael Van Canneyt michael at freepascal.org
Thu Jun 1 14:59:45 CEST 2017



On Thu, 1 Jun 2017, frans via Lazarus wrote:

> Hi.
> I'm using Lazarus 1.6.4 and FPC 3.0.2, combined with a Firebird 
> database. I've added all the fields of a table and use a datadictionary. 
> I show the data in de DBGrid and use a seperate form to manipulate the 
> data and to insert a new record.
> When inserting a new record, the DBGrid expands with a blank record. I 
> don't like that, I wish the DBGrid to show only the valid records and a 
> new record is not a valid record yet.
> 1. I've tried this with a query 'select * from dataset where number is 
> not null'. This doesn't work.
> 2. I've tried this with dataset.Disablecontrols (and enablecontrols), 
> this doesn't work either.
> 3. I've activated the option dgDisableInsert, that doesn't work either.
> The only solution I found is to use in the DBGrid a seperate view I 
> created in the database. It works, but I keep wondering if there is an 
> other solution possible.

I don't think so.

The grid shows what is in the dataset. An inserted record is in the dataset.
One possible way to do this is to collect all data for the new record in a 
not-data-aware manner, and only insert when it is complete.

Michael.


More information about the Lazarus mailing list