Microsoft KB Archive/94296

= BUG: Grid Control Paints Incorrectly When Press PGUP or PGDN =

Article ID: 94296

Article Last Modified on 10/30/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q94296



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.



Steps 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.</li> Place a grid control (Grid1) on Form1.</li>  Set the following properties for Grid1 to these values: <pre class="fixed_text">  Property      Value ---  Rows             12 Cols             3 FixedRows        2 FixedCols        1 </li> 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.</li>  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, &quot;0&quot;) Next End Sub </li> From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.</li> Set the focus to the grid.</li> 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).</li></ol>

Additional query words: buglist2.00 buglist3.00 2.00 3.00 buglist2.00 buglist3.00

Keywords: kbbug KB94296

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.