PRB: MSFLexGrid Redraw May Not Function Correctly (198938)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q198938 SYMPTOMS
After setting the TopRow property of the MSFlexGrid, setting the Redraw property to True does not cause the MSFlexGrid to be automatically redrawn.
CAUSE
Microsoft is researching this problem and will post new information in
the Microsoft Knowledge Base as it becomes available.
RESOLUTION
There are a couple of workarounds to this problem. You can use the code in these workarounds in place of the code shown in the MORE INFORMATION section of this article
- If you replace the MSFlexGrid1_Click() event in the MORE INFORMATION
section with the following code, it works as expected:
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
.Redraw = True
If .Row = .Rows - 1 Then
.TopRow = 2
Debug.Print "Right After Setting .Top Row: " & .TopRow
End If
End With
Debug.Print "After leaving With block: " & MSFlexGrid1.TopRow
End Sub
-or-
- Using the above workaround will get the MSFlexgrid to move to the
correct position. However, doing so may cause the grid to flicker when
filling. To avoid this flickering you can use the LockWindowUpdate
API call as noted in the below code. Instead of using the above code,
replace the code in the MSFlexGrid_Click() event with the following:
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hwndLock As Long) As Long
Private Sub fgrItemGrid_Click()
lres = LockWindowUpdate(Me.hWnd) 'Lock repaints
With fgrItemGrid
.Redraw = True
If .Row = .Rows - 1 Then
.TopRow = 2
Debug.Print "Right After Setting .Top Row: " & .TopRow
End If
End With
lres = LockWindowUpdate(0&) 'Release Lock
Debug.Print "After leaving With block: " & fgrItemGrid.TopRow
End Sub
NOTE: The LockWindowUpdate API can be used to enable or disable a window from repainting. In workaround 2 above, it is used to prevent the window from repainting.
STATUS
Microsoft is researching this problem and will post new information here in
the Microsoft Knowledge Base as it becomes available.
Modification Type: | Major | Last Reviewed: | 5/8/2003 |
---|
Keywords: | kbCtrl kbprb KB198938 |
---|
|