BUG: Grid Control Paints Incorrectly When Press PGUP or PGDN
ID: Q94296
|
The information in this article applies to:
-
Microsoft Visual Basic programming system for Windows, versions 2.0, 3.0
SYMPTOMS
The grid control may paint incorrectly when you press the PGUP or PGDN key.
Specifically, when you press the PGDN key to scroll down within a grid
control, the data in one column is painted in the next column.
WORKAROUND
This problem does not occur when you use the arrow keys or the mouse to
scroll within the grid.
You can work around the problem by refreshing the grid from within a timer.
The timer should be activated when the PGUP or PGDN key is pressed. Below
are the steps necessary to implement such a workaround:
- Add a timer control (Timer1) to Form1.
- Add the following code to the KeyDown event of Grid1:
Sub Grid1_KeyDown (KeyCode As Integer, Shift As Integer)
'Key codes for the pageup and pagedown keys
Const VK_PGUP = &H21 'VK_PRIOR
Const VK_PGDN = &H22 'VK_NEXT
If KeyCode = VK_PGUP Or KeyCode = VK_PGDN Then
Timer1.Interval = 1
Timer1.Enabled = True
End If
End Sub
- Add the following code to the Timer1_Timer event:
Sub Timer1_Timer ()
Grid1.Refresh
Timer1.Enabled = False
End Sub
When you press the PGUP or PGDN key, the timer event refreshes the grid.
STATUS
Microsoft has confirmed this to be a problem in the products listed above.
We are researching this problem and will post more information here in the
Microsoft Knowledge Base when it becomes available.
MORE INFORMATIONSteps to Reproduce Problem
- Run Visual Basic, or if Visual Basic is already running choose New
Project from the File menu (ALT, F, N). Form1 is created by default.
- From the File menu, choose Add File (ALT, F, D), and load GRID.VBX into
the project if it is not already loaded.
- Place a grid control (Grid1) on Form1.
- Set the following properties for Grid1 to these values:
Property Value
-------------------
Rows 12
Cols 3
FixedRows 2
FixedCols 1
- To make the PGUP and PGDN keys applicable, size the grid so that it has
fewer than the 12 rows and 3 columns you specified.
- Add the following code to the Form_Load event of Form1:
Sub Form_Load ()
Dim i As Integer
Grid1.Col = 1
'Fill the first non-fixed column with number from 1 to 11
For i = 2 To grid1.Rows - 1
Grid1.Row = i
Grid1.Text = Format$(i - 1, "0")
Next
End Sub
- From the Run menu, choose Start (ALT, R, S) or press the F5 key to run
the program.
- Set the focus to the grid.
- Press the PGDN key repetitively until the cursor is at the bottom of the
grid. Items from the first non-fixed column (the second column) are
incorrectly repeated in the second non-fixed column (the third column).
Additional query words:
buglist2.00 buglist3.00 2.00 3.00 buglist2.00 buglist3.00
Keywords :
Version :
Platform :
Issue type :
|