|
-
Mar 28th, 2005, 06:04 AM
#1
Thread Starter
Lively Member
FlexGrid
Hi,
i m facing the problem in the display on MSFlexGrid. For the address display , it will display it on the right side because it start with the house number in digit. Any idea I can solve this out. My coding are:
Public Sub flexgrid()
If rs_e.RecordCount <> 0 Then
G_RowCheck = rs_e.RecordCount
If rs_e.RecordCount > 25 Then
MSFlexGrid1.Rows = rs_e.RecordCount + 1
Else
MSFlexGrid1.Rows = 25
End If
End If
row_counter = 1
MSFlexGrid1.Clear
With MSFlexGrid1
.FormatString = "Enq No." & "|" & " First Name " & "|" & " Last Name " & "|" & " Date " & "|" & " Address " & "|" & "Hourse Phone" & "|" & "Mobile Phone" & "|" & " Email "
End With
While Not rs_e.EOF
With MSFlexGrid1
.Row = row_counter
.Col = 0
.Text = rs_e("EnqNo")
.Col = 1
.Text = rs_e("FirstName")
.Col = 2
.Text = rs_e("LastName")
.Col = 3
.Text = rs_e("EnqDate")
.Col = 4
.Text = rs_e("Address")
.Col = 5
.Text = rs_e("HPhone")
.Col = 6
.Text = rs_e("MPhone")
.Col = 7
.Text = rs_e("Email")
row_counter = row_counter + 1
End With
rs_e.MoveNext
Wend
End Sub
-
Mar 28th, 2005, 06:22 AM
#2
Addicted Member
Re: FlexGrid
You can do this change to your format string:
VB Code:
.FormatString = "Enq No." & "|" & " First Name " & "|" & " Last Name " & "|" & " Date " & "|[B]<[/B]" & " Address " & "|" & "Hourse Phone" & "|" & "Mobile Phone" & "|" & " Email "
-
Mar 28th, 2005, 07:19 AM
#3
Re: FlexGrid
As stated in the last post, the use of alignment characters will force the data in the column to be left, center or right justifed.
< is left, ^ is center and > is right justified.
Also - it might be better to load a grid like this:
Code:
Do While rsInquire.EOF = False ' Loop through the recordset now
lngRecCnt = lngRecCnt + 1
For z = 0 To rsInquire.Fields.Count - 1
strWhat = rsInquire(z) & "" ' The data element for this row/column
If strGridLine <> "" Then strGridLine = strGridLine & vbTab
strGridLine = strGridLine & strWhat
Next z
flxInput(lngGrid).AddItem strGridLine
strGridLine = ""
rsInquire.MoveNext
Loop
The .ADDITEM method puts a whole row at once.
Also, it does not require that you increment the .ROWS in advance - which I've seen others have problems with.
-
Mar 28th, 2005, 10:06 AM
#4
Thread Starter
Lively Member
Re: FlexGrid
Thank you for the reply.
Can you please give details code on the load a grid.
Thanks in advance
Vivian
-
Mar 28th, 2005, 10:19 AM
#5
Re: FlexGrid
Using your code as an example.
Code:
Dim strWhat as String, strGridLine as String
Dim z as Long
Do While rs_e.EOF = False ' Loop through the recordset now
For z = 0 To rs_e.Fields.Count - 1
strWhat = rs_e(z) & "" ' The data element for this row/column
' This assumes that the recordset has columns in order compared to the list you showed
' in your post - EnqNo, FirstName, LastName and so on
' Using & "" will make sure that a null value is turned into an empty string
If strGridLine <> "" Then strGridLine = strGridLine & vbTab
' Add a tab character to the string - separates the columns
strGridLine = strGridLine & strWhat
' Put the column onto the string
Next z
MSFlexGrid1.AddItem strGridLine
' This adds the row to the grid - all in one shot
strGridLine = ""
rs_e.MoveNext
Loop
If you have any questions - please post back.
-
Mar 28th, 2005, 11:41 AM
#6
Junior Member
Re: FlexGrid
You could also use the colAlignment property
e.g. FlexGrid1.ColAlignment(0) = flexAlignCenterCenter
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
|