FIX: Grid Custom Control RemoveItem Does Not Update RowHeight

Last reviewed: October 30, 1997
Article ID: Q85436
1.00 2.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 2.0 - Microsoft Professional Toolkit for Microsoft Visual Basic programming

  system for Windows, version 1.0

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.

MORE INFORMATION

Steps to Reproduce Problem

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

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

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

  4. Set the Grid1 Rows and Cols properties to 5.

  5. Place two command buttons (Command1 and Command2) on Form1.

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

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

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

  9. Click Command1. Note that the rows do not re-size.


Additional reference words: buglist1.00 buglist2.00 fixlist3.00 1.00 2.00
3.00
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsCus
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.