Results 1 to 6 of 6

Thread: FlexGrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Red face 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

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Posts
    176

    Re: FlexGrid

    You can do this change to your format string:
    VB Code:
    1. .FormatString = "Enq No." & "|" & " First Name " & "|" & " Last Name " & "|" & " Date " & "|[B]<[/B]" & " Address " & "|" & "Hourse Phone" & "|" & "Mobile Phone" & "|" & " Email "

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: FlexGrid

    Thank you for the reply.

    Can you please give details code on the load a grid.

    Thanks in advance
    Vivian

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    Junior Member
    Join Date
    Mar 2005
    Posts
    18

    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
  •  



Click Here to Expand Forum to Full Width