-
July 16th, 2002, 11:45 AM
#1
Having problems aligning numbers to the left of the cell, in an MSFlexGrid.
Before I load the data I set the horizontal and vertical alignment of data within the current cell to the left. FlexGrid.CellAlignment = 2. After I load the grid from the database, if any of the cells have data that contains a number, like '12', that cells data will be align to the right. How can I make all the data align left?
Thanks Jim
-
July 16th, 2002, 01:54 PM
#2
Hi Jim,
I'm not a FlexGrid expert, I actually align the text using the FormatString parameters:
Code:
Private Sub Command1_Click()
'Set the alignement for each colonne
Me.MSFlexGrid1.FormatString = "<LeftAlign |>RighAlign "
'Look the alignement
Me.MSFlexGrid1.TextMatrix(1, 0) = "Kobold"
Me.MSFlexGrid1.TextMatrix(1, 1) = "Kobold"
Me.MSFlexGrid1.AddItem "hello"
'The number will be align left
Me.MSFlexGrid1.AddItem "12"
End Sub
hope it helps -- Jeff
-
July 16th, 2002, 05:28 PM
#3
You can also align values in the centreusing the format string.
Me.MSFlexGrid1.FormatString = "^Center "
In code you can also use the cellalignment property to align values in a cell.
Thanks and Good Luck!!
zemp
-
July 17th, 2002, 02:24 AM
#4
To tell it in code...
'need to set the cellalignment of each cell. Thus you have to cycle
throug them. As you have to do it, you can assign values the old
way, without using textmatrix or textarray...
Code:
Option Explicit
Private Sub Form_Load()
Dim intCol, intRow
With MSFlexGrid1
.Cols = 5
.Rows = 5
For intRow = 1 To .Rows - 1
For intCol = 1 To .Cols - 1
.Row = intRow
.Col = intCol
'first put value
.Text = intRow
'then allign
.CellAlignment = flexAlignLeftCenter
Next
Next
End With
End Sub
Have happy coding,
Cesare Imperiali
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|