[SOLVED] DBGrid, set defaults when adding new Row lazarus / 16-Databases ---------------------------------------------------------------------- Zvoni · 2025-09-16 10:48 Hi Folks, never worked with the DB-aware controls, but this has to be RAD I have a DBGrid with a DBNavigator attached to it. Everything works, but..... I have 4 columns representing Booleans in the Database. When i add/insert a new row via DBNavigator, i get an "empty" Row in the Grid, with the 4 CheckBoxes having this "half state" checkmark. I've been looking for an Event (or whatever) of DBNavigator or DBGrid like "OnNewRow" or whatever to set some Defaults for those 4 Columns. Any ideas? EDIT: Just looked at and tested OnNewRecord and AfterInsert of the DataSource.Dataset No cigar. Those fire before the Row is added I need something after the Row in the Grid is added ---------------------------------------------------------------------- cdbc · 2025-09-16 11:01 Hi I'm as unfamiliar with these controls as you are, but does the grid fire an 'OnChange' event? Regards Benny ---------------------------------------------------------------------- Zvoni · 2025-09-16 11:04 Quote from: cdbc on September 16, 2025, 01:01:20 pmHi I'm as unfamiliar with these controls as you are, but does the grid fire an 'OnChange' event? Regards Benny Haven't found one, though i suspect most events are in the underlying Datasource/Dataset, since the Grid is (more or less) just a representation of the Datasource.Dataset ---------------------------------------------------------------------- paweld · 2025-09-16 11:11 Add a record with DBNavigator causes DataSet.Insert to be called, so the AfterInsert event is definitely OK. ---------------------------------------------------------------------- Zvoni · 2025-09-16 11:20 Quote from: paweld on September 16, 2025, 01:11:28 pmAdd a record with DBNavigator causes DataSet.Insert to be called, so the AfterInsert event is definitely OK. OK, i did try AfterInsert, but not to the end. I just set a breakpoint in the Event, and it fired before the new row was painted. Will report back EDIT: Reporting back. I'm an idiot for not trying AfterInsert to the End. Yepp. The Dataset is passed as the Argument. Setting FieldByName to the 4 Columns and setting the True/False for each one gives me exactly what i want. Thx Pawel ---------------------------------------------------------------------- Sieben · 2025-09-16 13:41 For setting defaults, I would recommend OnNewRecord since it does not set the Modified-Flag as opposed to AfterInsert. The Modified-Flag in turn affects the way Cancel is handled. ---------------------------------------------------------------------- Zvoni · 2025-09-16 14:15 Quote from: Sieben on September 16, 2025, 03:41:47 pmFor setting defaults, I would recommend OnNewRecord since it does not set the Modified-Flag as opposed to AfterInsert. The Modified-Flag in turn affects the way Cancel is handled. Hmm... OK Thx for the Info. Will have to keep an eye on it