DOC: Unbndgrd Sample App Updates Wrong Row
ID: Q185886
|
The information in this article applies to:
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, version 5.0
SUMMARY
This example is designed to demonstrate how to use the DBGrid control in an
unbound state. There is an error in the code for this example that can
cause strange results to occur when editing data in the example's DBGrid
control. Data that has been changed may appear to revert to previous
values, or changes entered in one row may be updated in another.
MORE INFORMATION
This situation has the potential to create a variety of problems. You
should implement the change to the sample code regardless of the behavior
you are seeing.
Resolution
- Open the code module for the Unbndgrd example's form.
- Locate the subroutine DBGrid1_UnboundReadData.
- In the subroutine, find the line of code that reads:
CurRow& = RowBuf.RowCount - 1
- Change the line of code to the following:
CurRow& = UBound(UserData, 2)
- The example should now function properly.
Steps to Reproduce Behavior
- Start Visual Basic (VB) and open the Unbndgrd.vbp sample project. (From
the VB directory go to \samples\Misc\UnBndGrd\Unbndgrd.VBP.)
- Run the project.
- Scroll the DBGrid down to the last row.
- Modify one of the cells.
- Click any row (except the last one) to update the grid.
- Note that the data reverts to its previous value.
- Scroll the DBGrid to the first row.
- Note that the changes appear in the first row.
This problem occurs only if the last row of the DBGrid is the first row to
be edited. After any other row has been edited, the DBGrid behaves
correctly.
Additional query words:
kbDSupport kbDSD kbCtrl
Keywords : kbGrpVB
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type :