DbGrid set first field to null after posting 1st record
Original Reporter info from Mantis: >8<
-
Reporter name: Bug Import
Original Reporter info from Mantis: >8<
- Reporter name: Bug Import
Description:
I have a project with a dbgrid where i get this error.
Not using dbgrid is OK
Assume that AField is a Integer Field and db is a TDataset
Here is the steps that lead to the bug:
Make sure first column in dbgrid (the default) is selected
1- Db.Append
2- AField.AsInteger:=ANumber
3- Db.Post
3.1 - Post triggers DataEvent(deUpdateRecord,0);
4-TCustomDbGrid.UpdateData;
4.1- GetFieldFromGridColumn(FEditingColumn) returns AField
4.2-edField.AsString := FTempText;-> Sets AField to Null (Calls TField.Clear=SetData(nil))
Some considerations:
- This only occurs when the dataset is empty (adding first record). In the next posts FEDitingColumn = -1 what lead to edField=nil (edField.AsString := FTempText not called)
- I tried to make a small example with only a dbgrid in it, but in this case the problem doesnt occur because GetFieldFromGridColumn(FEditingColumn) returns nil. The only difference between the original project and the small example is that in the last one
FieldIndexFromGridColumn returns -1 (column - FixedCols is equal to -1 differently of the first case) leading to GetFieldFromGridColumn return nil
Resuming the only difference between the 2 is the value of FixedCols
If necessary i can send the src of the project that shows the bug
Using fpc 1.9.8 + WindowsXP + Lazarus 0.9.7 + TSqlitedataset
Additional information:
Imported information
--------------------
Name: Luiz Americo
Mail: pascalive (at) bol.com.br
Mantis conversion info:
- Mantis ID: 740