Article ID: 198938
Article Last Modified on 5/8/2003
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-
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.
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
.Redraw = False
If .Row = .Rows - 1 Then
.TopRow = 2
Debug.Print "Right After Setting .Top Row: " & .TopRow
End If
.Redraw = True
'.Refresh
End With
Debug.Print "After leaving With block: " & MSFlexGrid1.TopRow
End Sub
Private Sub Form_Load()
With MSFlexGrid1
.RowHeightMin = 288
.Cols = 10
.Rows = 5
.TextMatrix(0, 1) = "Row 0"
.TextMatrix(1, 1) = "Row 1"
.TextMatrix(2, 1) = "Row 2"
.TextMatrix(3, 1) = "Row 3"
.TextMatrix(4, 1) = "Row 4"
.Width = 4095
.Height = 1600
End With
End Sub
Keywords: kbprb kbctrl KB198938