See Also Example
Applies To
Grid.
Description
Determines the width of the specified column in twips Not available at design time.
Usage
[form.]grid.ColWidth(column)[ = numericexpression ]
Remarks
You can use this property to set the width of any column at run time. Users can also change the width of a column by positioning the mouse pointer between columns and then clicking and dragging.
Data Type
Long
Help:
RowHeight Property
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
The example allows the user to increase the column width of selected columns with the > key, and decrease the column width with the < key. To try this example, create a new project, add GRID.VBX using the Add File command on the File menu, and then draw a grid.
Sub Form_Load ()
Grid1.Cols = 6 ' Set columns and rows.
Grid1.Rows = 8
End Sub
Sub Grid1_KeyPress (KeyAscii As Integer)
Select Case KeyAscii
Case 62 ' > key
' Get index for each selected column.
For I = Grid1.SelStartCol To Grid1.SelEndCol
' Increase column width.
Grid1.ColWidth(I) = Grid1.ColWidth(I) + 50
Next I
Case 60 ' < key
'Get index for each selected column.
For I = Grid1.SelStartCol To Grid1.SelEndCol
'Decrease column width.
Grid1.ColWidth(I) = Grid1.ColWidth(I) - 50
Next I
End Select
End Sub