Need help with MSFlexgrid formatstring.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Need help with MSFlexgrid formatstring.

  1. #1
    Join Date
    Nov 2006
    Posts
    103

    Need help with MSFlexgrid formatstring.

    I have a flexgrid with one column and many rows.
    How do I use the format string when there is only one column?


    for two columns this works...
    control.FormatString = "ROI Area" & "|<" & "ROI Max"

    but which column does the "|<" format? The first or the second?

  2. #2
    Join Date
    Sep 2006
    Posts
    635

    Re: Need help with MSFlexgrid formatstring.

    Code:
    control.FormatString = "Col_FIXED|COL1|COL2|COL3|"
    but which column does the "|<" format? The first or the second?
    answer is "|"

    now, if you don't want to use fixed column try out :
    Code:
    control.FormatString = "	 |COL1"

  3. #3
    Join Date
    Nov 2006
    Posts
    103

    Re: Need help with MSFlexgrid formatstring.

    I want the first and sole column to be centered text.

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,990

    Re: Need help with MSFlexgrid formatstring.

    Check this out:
    Code:
    Private Declare Function SetProp Lib "user32.dll" Alias "SetPropA" (ByVal hwnd As Long, ByVal lpString As String, ByVal hData As Long) As Long
    
    
    Private Sub Form_Load()
    Dim N, NN As Integer
    '\\Preparar grelha
    With GrHistorico
        .Cols = 8
        .Rows = 200
        .FixedCols = 0
        .FixedRows = 1
        .TextMatrix(0, 0) = "Data"
        .TextMatrix(0, 1) = "Utilizador"
        .TextMatrix(0, 2) = "Janela"
        .TextMatrix(0, 3) = "Operação"
        .TextMatrix(0, 4) = "Documento"
        .TextMatrix(0, 5) = "Divisa"
        .TextMatrix(0, 6) = "ID int."
        .TextMatrix(0, 7) = "Valorização"
        '\\Agora as medidas
        .ColWidth(0) = 1700
        .ColWidth(1) = 1200
        .ColWidth(2) = 4500
        .ColWidth(3) = 4500
        .ColWidth(4) = 4500
        .ColWidth(5) = 1000
        .ColWidth(6) = 1000
        .ColWidth(7) = 1300
        '\\Alinhamentos das colunas
        .ColAlignment(0) = flexAlignCenterCenter
        .ColAlignment(1) = flexAlignLeftCenter
        .ColAlignment(2) = flexAlignLeftCenter
        .ColAlignment(3) = flexAlignLeftCenter
        .ColAlignment(4) = flexAlignLeftCenter
        .ColAlignment(5) = flexAlignCenterCenter
        .ColAlignment(6) = flexAlignRightCenter
        .ColAlignment(7) = flexAlignRightCenter
        '\\Alinhamentos dos cabeçalhos
        .FixedAlignment(0) = flexAlignCenterCenter
        .FixedAlignment(1) = flexAlignLeftCenter
        .FixedAlignment(2) = flexAlignLeftCenter
        .FixedAlignment(3) = flexAlignLeftCenter
        .FixedAlignment(4) = flexAlignLeftCenter
        .FixedAlignment(5) = flexAlignCenterCenter
        .FixedAlignment(6) = flexAlignRightCenter
        .FixedAlignment(7) = flexAlignRightCenter
        'populate some rows and cols
        For N = 0 To 7
            For NN = 1 To 199
              .TextMatrix(NN, N) = "Just for testing ..."
            Next NN
        Next N
        
    End With
        
    SubClassMsGRID GrHistorico, Picture1
    End Sub
    
    Private Sub Form_Resize()
    On Error Resume Next
    GrHistorico.Move 300, 300, Me.ScaleWidth - 600, Me.ScaleHeight - 600
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    UnSubClassMsGRID GrHistorico.hwnd
    End Sub
    
    Private Sub GrHistorico_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    With GrHistorico
        SetProp .hwnd, "Click", .Row
        .Refresh
    End With
    End Sub
    ignore the subclassing stuff
    Last edited by dglienna; December 12th, 2007 at 04:21 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Nov 2006
    Posts
    103

    Re: Need help with MSFlexgrid formatstring.

    Thanks!

    Last question...
    The first column of the grid is grey/gray in color/colour...
    How can I make have the same color and behavior of the rest of the columns?

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,990

    Re: Need help with MSFlexgrid formatstring.

    how about .BackColor and .ForeColor
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Nov 2006
    Posts
    103

    Re: Need help with MSFlexgrid formatstring.

    I think my command line completion tool isn't working! lol.
    Thanks... doh!

  8. #8
    Join Date
    Nov 2006
    Posts
    103

    Need help with MSFlexgrid.

    Something is wierd with my flexgrid.
    I set selectionmode to flexSelectByRow

    in flexgrid click event I want to get the row that the user clicked on.
    however I notice that every thing from the first row to the row that the user clicked on is selected and the .row property is 1....

    I don't get it...

  9. #9
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,990

    Re: Need help with MSFlexgrid formatstring.

    try mouserow and mousecol
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Nov 2006
    Posts
    103

    Re: Need help with MSFlexgrid formatstring.

    Why is the previous selected row still highlighted as a selected row?
    Is there a flag for multiple selection that I'm not setting?
    I set the flag AllowBigSelection to false...
    But every thing above the current mouse click row is highlighted...
    Last edited by JustSomeGuy; December 14th, 2007 at 02:57 PM.

  11. #11
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,990

    Re: Need help with MSFlexgrid formatstring.

    No, but you can clear them all. I used to color the selected cells, and have to repaint them each time
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  12. #12
    Join Date
    Nov 2006
    Posts
    103

    Re: Need help with MSFlexgrid formatstring.

    Code:
    with gridname
       for i=0 to .rows
          HOW DO I SET THE BACKGROUND COLOR OF ROW I TO WHITE
       next
    end with

  13. #13
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,990

    Re: Need help with MSFlexgrid formatstring.

    Alternately!

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim i As Integer
    For i = 1 To flx.Rows - 1
      If i Mod 2 = 0 Then
        With flx
          .FillStyle = flexFillRepeat
          .Row = i
          .RowSel = i
          .Col = 1
          .ColSel = .Cols - 1
          .CellBackColor = vbRed
          .CellForeColor = vbWhite
        End With
      End If
    Next i
    flx.Row = 1
    End Sub
    
    Private Sub Form_Load()
      Dim i As Integer, j As Integer
      With flx
       For i = 1 To flx.Rows - 1
          For j = 0 To .Cols - 1
            .TextMatrix(i, j) = i & ", " & j
          Next j
      Next i
      End With
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center