FIX: Grid Custom Control RemoveItem Does Not Update RowHeight (85436)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 2.0
  • 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.

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.

Modification Type:MajorLast Reviewed:10/29/2003
Keywords:kbbug kbfix KB85436