The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a
SUMMARY
When you use a grid, based on two data sources, the grid may not display
properly when you navigate the master table with a custom toolbar while the
focus on the main form is in the grid.
The sample file Gridtest.exe contains an example that demonstrates this
problem.
The following file is available for download from the Microsoft Software
Library:
~ Gridtest.exe (size: 35143 bytes)
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591
TITLE : How to Obtain Microsoft Support Files from Online Services
MORE INFORMATION
Symptoms
Under the following conditions, a grid based on two tables will not
display the correct data:
- Focus is on the grid making one of the grid cells active.
- A toolbar button that skips to the next or previous record is clicked.
- The number of records in the grid exceeds the number of records that may
be displayed.
- The grid is scrolled.
Whether or not the scroll thumb or the scroll arrows are used to scroll the
grid determines how the data is misrepresented. In either case, the records
from the second table are misrepresented.
Resolution
Here are two possible workarounds:
- In the Click events of the navigation buttons on the toolbar, set the
focus on the main form to an object other than the grid. This is
demonstrated in the sample file with the form called Works. An example
of the code is as follows:
_SCREEN.ACTIVEFORM.txtF1.SETFOCUS
SELECT TBL1
SKIP 1
_SCREEN.ACTIVEFORM.REFRESH
(txtF1 is the name of a visible object on the form)
-or-
- Create a button on the main form that executes the following code:
THISFORM.GRID1.REFRESH
(Grid1 is the name of the grid)
Executing the refresh from a button on the custom toolbar does not solve
the problem.
See step 6 under Steps to Reproduce Behavior for this workaround.
NOTE: If the navigation buttons are objects on the form, this problem does
not occur.
Status
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
Steps to Reproduce Behavior
- Using the sample file run the form named Broken.
- Click the Next button located on the form. All the visible cells in the
first column of the grid should contain the number 2. Note that if
the grid is scrolled with either the scroll thumb or scroll arrows, all
the grid columns display correctly. The example below demonstrates
how the data should be displayed in the grid. The last row will not be
visible.
TBL2.F1 TBL2.F2 TBL3.F2 TBL3.F3
-----------------------------------------
2 a a Red
2 b b Blue
2 c c Green
2 d d Yellow
2 e e Brown
- Click in any cell of the grid. The grid now has focus on the form.
- Click the Previous button on the Toolbar, not the form.
- Scroll down the grid with the scroll thumb or slider. All the records in
the third column (TBL3.F2) will contain the letter "a." "Red" appears in
all the records of the fourth column (TLB3.F3). Using the scroll thumb,
scroll arrows, or clicking in one of the grid cells does not cause that
cell to refresh properly.
What should be displayed is the example shown in step 2 above with
the number 1 in the first grid column for all rows.
- Make sure that the focus is not in either the third or fourth grid
column, and then click the Grid Refresh button on the form. The grid
should now be back to normal. If one of the cells in the third or fourth
column had focus, it will not refresh, but all the others will. This
step implements the second workaround described in the Resolution
section above.
- Click in one of the grid cells, and then click the Next button on the
toolbar. The grid should move so that the number 2 is in the first
column (TBL2.F1). The data in the third and fourth columns should be
correct. Refer to the grid in step 2 above. Note that the last row
is not visible.
- Scroll the grid using the down scroll arrow. Note the values in the
third and fourth columns for the first visible record when you finish
scrolling.
If the scroll down was stopped, with only the last two records
displayed, and then the up scroll arrow is clicked, all the records
displayed from TBL3 will have the correct information. The example below
demonstrates how the data should be displayed in the grid.
TBL2.F1 TBL2.F2 TBL3.F2 TBL3.F3
--------------------------------------
2 a d Yellow
2 b d Yellow
2 c d Yellow
2 d d Yellow
2 e e Brown
If only the last record was visible when scrolling down stopped, then
all the records will contain an "e" in the third column (TBL3.F2)
and "Brown" in the fourth column (TBL3.F3) of the grid when
scrolling up.
- Modify the GridTtest.pjx sample project and examine the code in the
forms and visual classes.