[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:
Public Sub FlexGridColumnColor(FlexGrid As MSFlexGrid, ByVal lngColumn As Long, ByVal lngColor As Long)
Dim lngPrevCol As Long
Dim lngPrevColSel As Long
Dim lngPrevRow As Long
Dim lngPrevRowSel As Long
Dim lngPrevFillStyle As Long
If lngColumn > FlexGrid.Cols - 1 Then
Exit Sub
End If
lngPrevCol = FlexGrid.Col
lngPrevRow = FlexGrid.Row
lngPrevColSel = FlexGrid.ColSel
lngPrevRowSel = FlexGrid.RowSel
lngPrevFillStyle = FlexGrid.FillStyle
FlexGrid.Col = lngColumn
FlexGrid.Row = FlexGrid.FixedRows
FlexGrid.ColSel = lngColumn
FlexGrid.RowSel = FlexGrid.Rows - 1
FlexGrid.FillStyle = flexFillRepeat
FlexGrid.CellBackColor = lngColor
FlexGrid.Col = lngPrevCol
FlexGrid.Row = lngPrevRow
FlexGrid.ColSel = lngPrevColSel
FlexGrid.RowSel = lngPrevRowSel
FlexGrid.FillStyle = lngPrevFillStyle
End Sub
Public Sub FlexGridRowColor(FlexGrid As MSFlexGrid, ByVal lngRow As Long, ByVal lngColor As Long)
Dim lngPrevCol As Long
Dim lngPrevColSel As Long
Dim lngPrevRow As Long
Dim lngPrevRowSel As Long
Dim lngPrevFillStyle As Long
If lngRow > FlexGrid.Rows - 1 Then
Exit Sub
End If
lngPrevCol = FlexGrid.Col
lngPrevRow = FlexGrid.Row
lngPrevColSel = FlexGrid.ColSel
lngPrevRowSel = FlexGrid.RowSel
lngPrevFillStyle = FlexGrid.FillStyle
FlexGrid.Col = FlexGrid.FixedCols
FlexGrid.Row = lngRow
FlexGrid.ColSel = FlexGrid.Cols - 1
FlexGrid.RowSel = lngRow
FlexGrid.FillStyle = flexFillRepeat
FlexGrid.CellBackColor = lngColor
FlexGrid.Col = lngPrevCol
FlexGrid.Row = lngPrevRow
FlexGrid.ColSel = lngPrevColSel
FlexGrid.RowSel = lngPrevRowSel
FlexGrid.FillStyle = lngPrevFillStyle
End Sub
Example:
VB Code:
Call FlexGridColumnColor(MSFlexGrid, 2, vbRed)
Call FlexGridRowColor(MSFlexGrid, 3, vbBlue)
Hope that helps someone :)
Cheers,
RyanJ
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 :)