Results 1 to 2 of 2

Thread: [VB6 Snippet] Changing Complete Column Or Row Colour in FlexGrid

  1. #1

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    [VB6 Snippet] Changing Complete Column Or Row Colour in FlexGrid

    Title: Changing Complete Column Or Row Colour in MS FlexGrig Control.
    Description: Changes a whole row or columns colour in a FlexGrid control.
    Feature List: N/A
    Screen-shots: None
    Author Name: Ryan Jones
    System Requirements: Any - Tested in Win 98, ME, 2000.
    License Info: Any - use and modify as you like.

    VB Code:
    1. Public Sub FlexGridColumnColor(FlexGrid As MSFlexGrid, ByVal lngColumn As Long, ByVal lngColor As Long)
    2.     Dim lngPrevCol As Long
    3.     Dim lngPrevColSel As Long
    4.     Dim lngPrevRow As Long
    5.     Dim lngPrevRowSel As Long
    6.     Dim lngPrevFillStyle As Long
    7.     If lngColumn > FlexGrid.Cols - 1 Then
    8.         Exit Sub
    9.     End If
    10.     lngPrevCol = FlexGrid.Col
    11.     lngPrevRow = FlexGrid.Row
    12.     lngPrevColSel = FlexGrid.ColSel
    13.     lngPrevRowSel = FlexGrid.RowSel
    14.     lngPrevFillStyle = FlexGrid.FillStyle
    15.     FlexGrid.Col = lngColumn
    16.     FlexGrid.Row = FlexGrid.FixedRows
    17.     FlexGrid.ColSel = lngColumn
    18.     FlexGrid.RowSel = FlexGrid.Rows - 1
    19.     FlexGrid.FillStyle = flexFillRepeat
    20.     FlexGrid.CellBackColor = lngColor
    21.     FlexGrid.Col = lngPrevCol
    22.     FlexGrid.Row = lngPrevRow
    23.     FlexGrid.ColSel = lngPrevColSel
    24.     FlexGrid.RowSel = lngPrevRowSel
    25.     FlexGrid.FillStyle = lngPrevFillStyle
    26. End Sub
    27.  
    28. Public Sub FlexGridRowColor(FlexGrid As MSFlexGrid, ByVal lngRow As Long, ByVal lngColor As Long)
    29.     Dim lngPrevCol As Long
    30.     Dim lngPrevColSel As Long
    31.     Dim lngPrevRow As Long
    32.     Dim lngPrevRowSel As Long
    33.     Dim lngPrevFillStyle As Long
    34.     If lngRow > FlexGrid.Rows - 1 Then
    35.         Exit Sub
    36.     End If
    37.     lngPrevCol = FlexGrid.Col
    38.     lngPrevRow = FlexGrid.Row
    39.     lngPrevColSel = FlexGrid.ColSel
    40.     lngPrevRowSel = FlexGrid.RowSel
    41.     lngPrevFillStyle = FlexGrid.FillStyle
    42.     FlexGrid.Col = FlexGrid.FixedCols
    43.     FlexGrid.Row = lngRow
    44.     FlexGrid.ColSel = FlexGrid.Cols - 1
    45.     FlexGrid.RowSel = lngRow
    46.     FlexGrid.FillStyle = flexFillRepeat
    47.     FlexGrid.CellBackColor = lngColor
    48.     FlexGrid.Col = lngPrevCol
    49.     FlexGrid.Row = lngPrevRow
    50.     FlexGrid.ColSel = lngPrevColSel
    51.     FlexGrid.RowSel = lngPrevRowSel
    52.     FlexGrid.FillStyle = lngPrevFillStyle
    53. End Sub

    Example:

    VB Code:
    1. Call FlexGridColumnColor(MSFlexGrid, 2, vbRed)
    2. Call FlexGridRowColor(MSFlexGrid, 3, vbBlue)

    Hope that helps someone

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: [VB6 Snippet] Changing Complete Column Or Row Colour in FlexGrid

    I've moved it to the codebank. I thought it was more fitting since it's not a tutorial


    Has someone helped you? Then you can Rate their helpful 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
  •  



Click Here to Expand Forum to Full Width