ColWidth Property

See AlsoBS2RN5              Example7EE49CQ>Low

Applies To

Grid2VGT0PT.

Description

Determines the width of the specified column in twips2SWJ8D3.  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

Long103F6YL


See Also

Help:

RowHeight Property5NQLDX

 

Programmer's Guide:

Chapter 3, "Creating and Using Controls"


ColWidth Property Example

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