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:

  1. Add a timer control (Timer1) to Form1.


  2. 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 


  3. 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 INFORMATION

Steps to Reproduce Problem

  1. 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.


  2. From the File menu, choose Add File (ALT, F, D), and load GRID.VBX into the project if it is not already loaded.


  3. Place a grid control (Grid1) on Form1.


  4. Set the following properties for Grid1 to these values:
    
       Property      Value
       -------------------
       Rows             12
       Cols              3
       FixedRows         2
       FixedCols         1 


  5. 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.


  6. 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 


  7. From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.


  8. Set the focus to the grid.


  9. 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 :


Last Reviewed: August 19, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.