TDBGrid on a TPageControl generates "List index out of bounds" error due to spurious exit event
Original Reporter info from Mantis: luca @olivluca
-
Reporter name: Luca Olivetti
Original Reporter info from Mantis: luca @olivluca
- Reporter name: Luca Olivetti
Description:
When you place a TDbgrid on a TTabSheet while appending a record and clicking on another cell of the same record, a spurious exit event is generated which cancels the edit and eventually causes a "list index out of bounds" error since the record is no longer there.
No such spurious exit event is generated if there's no TPageControl/TTabSheet on the form.
Steps to reproduce:
In the attached project:
- go to the last record in either grid
- use the keyboard down arrow. A new record is appended. Don't type anything in the edit box
- use the mouse to click on another cell of the same (appended) record
A "list index out of bounds" exception is generated. If you then click the button to remove the pagecontrol and repeat the steps, no exception is generated.
Additional information:
If you put a breakpoint on the procedure TCustomDBGrid.DoExit (lcl/dbgrids.pas) you'll see that step 3 will trigger the breakpoint when there's a pagecontrol and won't trigger it without.
That procedure will cancel the edit, hence causing the exception.
As a workaround I set dgCancelOnEdit to false, so that the procedure doesn't cancel the edit.
Mantis conversion info:
- Mantis ID: 26916
- Version: 1.2.6
- Fixed in version: 1.3 (SVN)
- Fixed in revision: 46642 (#edd7ba66)
- Target version: 1.4