I have a form with a TDBGrid associate to a DataSet with 3 records and I
getting the following excepcion when i try to select a record from the
grid.
'Grid Index out of Range'
What am i doing wrong?
Thanks in advance,
Tico.
You're probably not doing anything wrong. This is an error that
I've experienced also, and it came out of nowhere when I was
working on my project. Using the exact same code, one day
everything was working fine, the next day I got the error message.
The way I "fixed" it was to disconnect the visual controls from
the dataset when I was iterating through records in code. I did
this by setting the datasource's Enabled property to false prior
to starting the iteration, and then setting it to true after
starting the iteration. Haven't seen the "Grid Index Out of Bounds"
error since.
Hope that helps.
Hi,
I've also had exactly the same problem. My problem has started to occur
since I have roughly 50 tables (I would say that roughly 30 are open at
the one time). Has any one else had this sort of problem?
I would love to know a proper fix - as the above suggested fix only
worked "sometimes" - I have one table that I used this fix for - with no
luck.
Sincerely
Walter Brandt
Assume you connect your TableXXX object with DatasourceXXX object and
DBGridXXX object with DataSourceXXX object.
When you call the methotds TableXXX.First, .Next , .Last, .Prior you can get
message "Grid index is out of range". I cannot why, but I found:
Solution 1.
At design-time set:
DBGrid.DataSource := nil
and set:
DBGridXXX.DataSource := DataSourceXXX;
at run-time when you want to see your DBGridXXX columns
Solution 2
before calling TableXXX.First, .Next , .Last, .Prior set:
DBGridXXX.DataSource := nil;
after calling those methods set old(original) value
DBGridXXX.DataSource := DataSourceXXX;
Good Luck
-----
Eugene Kovalov
Dnepropetrovsk, Ukraine
Hi fellows!
I had some troubles like the ones you describes here when i was using the
TStringGrid component. I tried to move the current cell by altering the Row
and Col properites of the component. At first it worked fine but then
suddenly it stopped working. I found that the problem was due to a prior
made selection in the grid. If i tried to set the "cursor" to a cell wich
was outside the selection i got the message "Grid Index out of range" eaven
if the cell itself was valid. I solved it by moving the selection to cover
the cell wich i wanted to move to.
This was another problem but it took me several hours to figure out what
was happening. Perhaps it could be something simmilar in your problems,
otherwise this article may help someone who struggles with the same problem
i had.
Thanks for your time, Tomas
You may also add DisableControls/EnableControls to your code
before you perform any data commands:
with table1 do begin
DisableControls;
First;
while not eof do begin
...
next;.
end;
EnableControls;
end;
This sould solve your problem
Scott.
Eugene A. Kovalov wrote:
> "Tico" <a.pe...@codetel.net.do> 15 Apr wrote:
> >I have a form with a TDBGrid associate to a DataSet with 3 records
> and I
> >getting the following excepcion when i try to select a record from
> the
> >grid.
> >'Grid Index out of Range'
> >What am i doing wrong?
--
Scott Martin
Kvaerner FSSL, Inc.
sma...@firstnethou.com