Board index » delphi » Strange Error using a DBGrid

Strange Error using a DBGrid

Hi everyone.  I hope someone can help me with this small (I think)
problem I have.

It's happened in 3 or 4 different applications I've built.  When I use a
DBGrid on a TPageControl, and it's not on the tab that first appears
when you start the program, I get this error:

Grid Index out of range.

If the first thing I do is choose that tab, the program runs OK, but if
I do processing that uses the table defined in the grid, I get the
error.  When I make that tab the first tab that show up when I start the
program, everything is fine.

I suspect it must be something I overlooked, but for the life of me, I
can't find out what it is.  Any and all help is appreciated.

Marc

 

Re:Strange Error using a DBGrid


Quote
Marc Charron <m...@unicate.com> wrote:
>Grid Index out of range.
>If the first thing I do is choose that tab, the program runs OK, but if
>I do processing that uses the table defined in the grid, I get the
>error.  When I make that tab the first tab that show up when I start the
>program, everything is fine.

Whenever you do some processing on the table, the dbgrid gets an event
which causes it to repaint itself. Whenever it is not visible, like in
your case, you will get this error. You can work around this by
setting the datasource-property of the dbgrid to nil and set it to the
table when the tab is activated and reset it to nil when leaving the
tab.

Other Threads