VB Grid: Changing Font Properties Resets ColWidth, RowHeight

ID Number: Q81463

1.00

WINDOWS

Summary:

Changing the FontBold, FontName, or FontSize property of the Grid

custom control at run time will reset the Grid's ColWidth and

RowHeight properties to the default values for the newly specified

font property. As a result, you may need to reset the ColWidth and

RowHeight properties when you change a Font property at run time. This

behavior is by design.

This information applies to the Grid custom control supplied with

Microsoft Professional Toolkit for Microsoft Visual Basic programming

system version 1.0 for Windows.

More Information:

To reproduce this behavior, do the following:

1. Run 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 (CTRL+F12). In the Files box,

select the GRID.VBX custom control file. The Grid tool will appear

in the toolbox.

3. Add the Grid control to Form1 and set the Grid's properties as

follows:

Property Value

-------- -----

Height 950

Width 2650

4. Add the following code to the Form_Load event procedure.

Sub Form_Load ()

Grid1.ColWidth(0) = 2000

Grid1.RowHeight(0) = 500

Grid1.Row = 0

Grid1.Col = 0

Grid1.Text = "Howdy, Cowboy!!!"

End Sub

5. Add the following code to the Grid_Click event procedure.

Sub Grid_Click ()

Grid1.FontBold = 0 ' Any of these statements will

' Grid1.FontSize = 12 ' cause the ColWidth and

' Grid1.FontName = "Courier" ' RowHeight to reset.

End Sub

6. From the Run menu, choose Start (ALT, R, S) to run the program.

When you run the program, the upper left cell is large enough to

contain the phrase "Howdy, Cowboy!!!". Notice that clicking the Grid

control to change a Font property causes the cell size to reset to its

default size, and that the phrase "Howdy, Cowboy!!!" is no longer

completely displayed.

Additional reference words: 1.00