See Also Example
Applies To
Grid.
Description
Determines the alignment of data in a column. Not available at design time.
Usage
[form.]grid.ColAlignment(column)[ = numericexpression ]
Setting
The ColAlignment property settings are:
Setting Description
0 (Default) Left align
1 Right align
2 Center
Remarks
Any column can have an alignment that is different from other columns. This property does not affect cells in a fixed row. To set the alignment for a fixed column, use the FixedAlignment property.
Data Type
Integer (Enumerated)
Help:
Alignment Property
FixedAlignment Property
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
The example fills a grid with the letter "m" and then sets the column alignment to right-aligned for every other column. To try this example, use the Add File command on the File menu to add GRID.VBX to the project, and then draw a grid on a new form. To run the program, press F5.
Sub Form_Load ()
Grid1.Cols = 5 ' Set Cols and Rows.
Grid1.Rows = 8
' Select all cells
Grid1.SelStartCol = 1
Grid1.SelStartRow = 1
Grid1.SelEndCol = Grid1.Cols - 1
Grid1.SelEndRow = Grid1.Rows - 1
' Fill all cells with a letter
Grid1.FillStyle = 1 ' Turn on FillStyle.
Grid1.Text = "m"
' Set ColAlignment for even numbered columns
For I = 2 To 4 Step 2
Grid1.ColAlignment(I) = 1 ' Right align.
Next I
Grid1.FillStyle = 0 ' Turn off FillStyle.
End Sub