Microsoft KB Archive/85436

= FIX: Grid Custom Control RemoveItem Does Not Update RowHeight =

Article ID: 85436

Article Last Modified on 10/29/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Professional Toolkit for Microsoft Visual Basic programming system for Windows

-



This article was previously published under Q85436



SYMPTOMS
If you change the RowHeight property of a Grid control, and then delete a row by using the RemoveItem method, the grid adjusts the height of the rows below the deleted row to their default size. However, it does not update the RowHeight property for those rows. If you reset the RowHeight property to its current value, the Grid does not re-draw the rows to the size given by RowHeight.



WORKAROUND
To work around the problem, set RowHeight to a different value and then change it back to the original value.

For example, replace the code shown in the Command1 Click event in step 6 of the More Information section below with this code: Sub Command1_Click For count% = 0 To Grid1.Rows - 1 Grid1.RowHeight(count%) = 399 Next count%

For count% = 0 To Grid1.Rows - 1 Grid1.RowHeight(count%) = 400 Next count% End Sub



STATUS
Microsoft has confirmed this to be a bug in the Grid custom control supplied with the products listed above. This problem was corrected in the Grid custom control shipped with Microsoft Visual Basic version 3.0 for Windows.



Steps to Reproduce Problem
 Start Visual Basic, or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. From the File menu, choose Add File. In the Files box, select the GRID.VBX custom control file. The Grid tool will appear in the toolbox. Place a Grid control (Grid1) on Form1. Set the Grid1 Rows and Cols properties to 5. Place two command buttons (Command1 and Command2) on Form1.  Place the following code in the Command1 Click event: Sub Command1_Click For count% = 0 To Grid1.Rows - 1 Grid1.RowHeight(count%) = 400 Next count% End Sub </li>  Place the following code in the Command2 Click event: Sub Command2_Click Grid1.RemoveItem 1 For count% = 0 To Grid1.Rows - 1 Debug.Print Grid1.RowHeight(count%) Next count% End Sub </li> Press F5 to run the program. Click the Command1 button to set the RowHeight properties to 400. Click Command2 to remove a row.

Notice that the grid rows are re-sized even though the output in the Immediate window shows that the RowHeight property has not changed.</li> Click Command1. Note that the rows do not re-size.</li></ol>

Additional query words: buglist1.00 buglist2.00 fixlist3.00 1.00 2.00 3.00

Keywords: kbbug kbfix KB85436

-

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

© Microsoft Corporation. All rights reserved.