Results 1 to 5 of 5

Thread: [RESOLVED] MSFlexgrid Font Issue

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Resolved [RESOLVED] MSFlexgrid Font Issue

    Hi All,

    Is it possible to make different columns in an MSFlexgrid set to different font styles. I want for example Column 1 to be the font type "Marlett" and Column 2 to be of the font type "Arial".

    Please help.

    Thanks.

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: MSFlexgrid Font Issue

    I think you can use sendmessage with WM_SETFONT
    http://msdn2.microsoft.com/en-us/library/ms632642.aspx

    SendMessage m_hWnd, WM_SETFONT, m_hFnt, 1
    Last edited by Fazi; Jul 10th, 2007 at 04:57 AM.

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: MSFlexgrid Font Issue

    Play around with this:
    Code:
    Private Sub Command1_Click()
        setColumnFont MSFlexGrid1, True, 2, "Arial", 10, True, False, False, False
        setColumnFont MSFlexGrid1, False, 4, "Marlett", 12, False, True, True, False
    End Sub
    
    Sub setColumnFont(mfg As MSFlexGrid, _
                      withHeader As Boolean, _
                      column As Integer, _
                      fontName As String, _
                      fontSize As Integer, _
                      fontBold As Boolean, _
                      fontItalic As Boolean, _
                      fontUnderline As Boolean, _
                      fontStrikeThrough As Boolean)
        Dim intI As Integer
        Dim intStart As Integer, intEnd As Integer
        Dim intRow As Integer, intRowSel As Integer, intCol As Integer, intColSel As Integer
    
        With mfg
            .Visible = False
    
            intRow = .Row
            intRowSel = .RowSel
            intCol = .Col
            intColSel = .ColSel
    
            .Col = (column - 1)
    
            If withHeader Then
                intStart = 0
                intEnd = (.Rows - 1)
            Else
                intStart = .FixedRows
                intEnd = (.Rows - intEnd - 1)
            End If
    
            For intI = intStart To intEnd
                .Row = intI
    
                .CellFontName = fontName
                .CellFontSize = fontSize
                .CellFontBold = fontBold
                .CellFontItalic = fontItalic
                .CellFontUnderline = fontUnderline
                .CellFontStrikeThrough = fontStrikeThrough
            Next intI
    
            .Row = intRow
            .RowSel = intRowSel
            .Col = intCol
            .ColSel = intColSel
    
            .Visible = True
        End With
    End Sub

  4. #4

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Thumbs up Re: MSFlexgrid Font Issue

    Quote Originally Posted by gavio
    Play around with this:
    Code:
    Private Sub Command1_Click()
        setColumnFont MSFlexGrid1, True, 2, "Arial", 10, True, False, False, False
        setColumnFont MSFlexGrid1, False, 4, "Marlett", 12, False, True, True, False
    End Sub
    
    Sub setColumnFont(mfg As MSFlexGrid, _
                      withHeader As Boolean, _
                      column As Integer, _
                      fontName As String, _
                      fontSize As Integer, _
                      fontBold As Boolean, _
                      fontItalic As Boolean, _
                      fontUnderline As Boolean, _
                      fontStrikeThrough As Boolean)
        Dim intI As Integer
        Dim intStart As Integer, intEnd As Integer
        Dim intRow As Integer, intRowSel As Integer, intCol As Integer, intColSel As Integer
    
        With mfg
            .Visible = False
    
            intRow = .Row
            intRowSel = .RowSel
            intCol = .Col
            intColSel = .ColSel
    
            .Col = (column - 1)
    
            If withHeader Then
                intStart = 0
                intEnd = (.Rows - 1)
            Else
                intStart = .FixedRows
                intEnd = (.Rows - intEnd - 1)
            End If
    
            For intI = intStart To intEnd
                .Row = intI
    
                .CellFontName = fontName
                .CellFontSize = fontSize
                .CellFontBold = fontBold
                .CellFontItalic = fontItalic
                .CellFontUnderline = fontUnderline
                .CellFontStrikeThrough = fontStrikeThrough
            Next intI
    
            .Row = intRow
            .RowSel = intRowSel
            .Col = intCol
            .ColSel = intColSel
    
            .Visible = True
        End With
    End Sub
    Wow,
    Thanks alot Gavio. It's working perfectly.

  5. #5

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