Board index » delphi » DBGrid : Index out of range ????

DBGrid : Index out of range ????

I know it's a piece of cake for you, so
Please help me to solve problem with DBGrid .....

I have 2 forms : Form1 and Form2
Form1 contains : DBGrid1, Table1, Source1, Button1
Form2          : Table2, Source2, and a plenty of DBEdit's
and
Table1 and Table2 uses to the same (PERS.DB) Paradox table.
Form2 is used to insert rows into Table2 (PERS.DB)
Button1 is used to FORM2.ShowModal

Important : DBGrid1 height is enough to display 3 rows.

The problem is :

When Paradox table contains 1 or 2 records
when I push Button1 to add new record, Form2 appears and everything
is OK. When I post the new record and close form2, I returns to form1. OK

DBGrid1 does not display the added record, OK
BUT WHEN I SCROLL DBGRID1 UP AND DOWN TO REPAINT IT I GET A MESSAGE :

    GRID INDEX OUT OF RANGE

So tell me what should I do after adding a new record in Form2
to see this record in DBGrid1 in Form1 ?????

Thanks Mike

P.S1. Please answer me at my e-mail :

P.S2 When PERS.DB contains more than 3 records everything is OK

Mike

 

Re:DBGrid : Index out of range ????


Quote
krzy...@zeus.polsl.gliwice.pl (Michal Krzycki) wrote:

If you use: Table1.DisableControls before you update your table,
then Table1.EnableControls after the update, this should fix your
problem.

This will 'unlink' the grid from the table will it is being updated.
BORLAND SHOULD FIX THIS? (Grrr)! :)

Hope this helps,
Scott

Quote
>I know it's a piece of cake for you, so
>Please help me to solve problem with DBGrid .....
>I have 2 forms : Form1 and Form2
>Form1 contains : DBGrid1, Table1, Source1, Button1
>Form2          : Table2, Source2, and a plenty of DBEdit's
>and
>Table1 and Table2 uses to the same (PERS.DB) Paradox table.
>Form2 is used to insert rows into Table2 (PERS.DB)
>Button1 is used to FORM2.ShowModal
>Important : DBGrid1 height is enough to display 3 rows.
>The problem is :
>When Paradox table contains 1 or 2 records
>when I push Button1 to add new record, Form2 appears and everything
>is OK. When I post the new record and close form2, I returns to form1. OK
>DBGrid1 does not display the added record, OK
>BUT WHEN I SCROLL DBGRID1 UP AND DOWN TO REPAINT IT I GET A MESSAGE :
>    GRID INDEX OUT OF RANGE
>So tell me what should I do after adding a new record in Form2
>to see this record in DBGrid1 in Form1 ?????
>Thanks Mike
>P.S1. Please answer me at my e-mail :
>P.S2 When PERS.DB contains more than 3 records everything is OK
>Mike

-
Scott Martin/MIS
Kvaerner FSSL, Inc.
smar...@firstnethou.com

Other Threads