Solved

Grid Index Out of Range

Posted on 1997-05-01
4
1,925 Views
Last Modified: 2008-02-26
We are getting a Grid Index out of Range error when scrolling through the records (every record) in a TwwDBGrid component.

Has anyone ever encountered this error?

What is being tested here to determine the out of range state ?  

We are using a master/detail table arrangement and displaying the detail records in the grid associated with the link field in the Master Table.

We are using Infopower's TwwDBGrid component.  This is a great component except when the above described nonsense occurs.  Naturally, nobody has any idea of what causes this problem.  We would like to figure out what we have to do either to some property (unknown) in the TDBGrid or our database structure to correct the problem.  

0
Comment
Question by:billmee
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
javiertb earned 110 total points
ID: 1335846
It seems to be one of those Delphi bugs, but here you have several options which may help you:

-Do not link at definition time more than one form to the same DataSet.

-Before making that call to the last record, set the datasource
Enabled property to false, then set it to True after calling Last record. If you're looping through several records at a time, set the Enabled property prior to entering the loop and reset it after leaving the loop.

-If you have hidden grids (for example on other tab pages) you may get the error when the database gets to the end. The easiest way to avoid the error is to use the onshow events of the tab pages or forms to enable the grid and the onhide event to disable the grid, this way the error doesn't seem to happen.

Hope this helps
0
 

Author Comment

by:billmee
ID: 1335847
Perhaps I need to provide you with some more information and vice versa before I can evaluate your response to my question.

On a DBGrid component tied to a datasource which in turn is linked to a Detail Table the display of records in the grid field is completely automatic.  The Master TTable component contains the field linkage between itself and the detail component.  On form activate we initiate a query which refreshs the records displayed in the detail table.  There is no onScroll event associated with the DBGrid component. The scrolling of the displayed records is handled automatically by the component so we have no programmatic control over the display of the records in the DBGrid. The collection of records is in fact displayed.  It is just when one clicks the scroll bar arrow that the Grid Index Out of Range error pops up.

The DBGrid is on the main form and is not resident on a tabbed notebook page.
0
 
LVL 2

Expert Comment

by:javiertb
ID: 1335848
Make sure you have no other DataSource associated to the same dataset when you access this DBGrid. If so, set it by DataSource.DisableControls.
If still isn't working, maybe the problem is on the TwwDBGrid, as I've been talking with people about the same bug, and all of them  got to solve it by doing what I told you.


0
 

Author Comment

by:billmee
ID: 1335849
Javier,

Thankyou for your time and your thoughtful response.  I am going to make certain that the table in question is not being accessed by any other datasource on another form.

Bill Mee
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now