DBGrid shows an error when trying to select a record via the event OnCellClick
Original Reporter info from Mantis: gbasisty
-
Reporter name: German C. Basisty
Original Reporter info from Mantis: gbasisty
- Reporter name: German C. Basisty
Description:
Example case:
I have a DB running on PostgreSQL with a table with 3 fields, for example name, address, phone. I have a form with a DBGrid (works properly), and I try to recover a register and put the 3 values on 3 local variables. To do so I use the OnCellClick event this way:
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
name := SQLQuery1.FieldByName('name').AsString;
address := SQLQuery1.FieldByName('address').AsString;
phone := SQLQuery1.FieldByName('phone').AsString;
end;
Now, when I click on the first column (the first field) of any register, it works fine. But when I click on any other column it shows an error message who says
list index (-1) out of bounds
It happens all the time!
Here using lazarus 0.9.29 SVN 28334 FPC 2.4.2 running on windows 7 32 bits.
Regards.-
German C. Basisty
Mantis conversion info:
- Mantis ID: 17984
- Version: 0.9.29 (SVN)
- Target version: 0.99.0