Why won't the following code color my col header cells. As the following Debug output indicates, the
.iGrid1.ColHeaderBackColor(i) = 15132391 and .iGrid1.ColHeaderBackColor(i) = 11389944
statements seem to set the right values, but when the grid is shown, the header cells aren't coloured.
However the
.iGrid1.ColHeaderText(i) = "AAAA"
statement does update the header text and this is shown on the grid
Sub expenseEntry()
Dim colHeader As Object
Dim gridWidth, i As Long
With uExpEntryDlg
.acTypeCB.AddItem ("Expense")
.acTypeCB.AddItem ("Income")
.acTypeCB.AddItem ("Cap Movt")
.acTypeCB.AddItem ("ExtraOrdinary Expense")
.acTypeCB.AddItem ("Miscx")
.acTypeCB.AddItem ("XXXXX")
.acTypeCB.ListIndex = 0
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=36, sHeader:="A/C#")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=144, sHeader:="A/C Name")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=360, sHeader:="Transaction Description")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=72, sHeader:="Trans Date")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=118, sHeader:="Amount")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=18, sHeader:="Tax")
fillCol
Set colHeader = .iGrid1.AddCol(lWidth:=118, sHeader:="Project")
fillCol
For i = 1 To 11
If i Mod 2 = 1 Then
addUnselectableRow (i)
Else
.iGrid1.AddRow lHeight:=18
End If
Next i
colorActiveCells
' .iGrid1.Header.BackColor = g_MidOrangeColor
'Colour Col Header Cells
For i = 1 To 5
If i Mod 2 = 1 Then
.iGrid1.ColHeaderBackColor(i) = 15132391 'g_PaleGrayColor
Else
.iGrid1.ColHeaderText(i) = "AAAA"
.iGrid1.ColHeaderBackColor(i) = 11389944 'g_MidOrangeColor
End If
Debug.Print i & " " & .iGrid1.ColHeaderText(i) & " " & .iGrid1.ColHeaderBackColor(i)
Next i
'Adjust Grid width = Sum (col widths)
getScreenInfo
gridWidth = 890 + 4 '4 for left and right grid boundaries [= 4+36+144+360+72+118+18+118+[8*unselectableColWidth] = 870+8*uscw
.iGrid1.width = gridWidth / mptCurrentDPI.X * 72 'points = pixels/(pixels/In)*72 points per Inch
.Show
End With
End Sub
Sub fillCol()
With uExpEntryDlg.iGrid1.AddCol(lWidth:=3)
.bSelectable = False
.oBackColor = g_PaleGrayColor
End With
End Sub
Sub addUnselectableRow(r)
Dim cRow, cCol As Long
uExpEntryDlg.iGrid1.AddRow lHeight:=3
For c = 1 To 15
uExpEntryDlg.iGrid1.CellSelectable(r, c) = False
uExpEntryDlg.iGrid1.CellBackColor(r, c) = g_PaleGrayColor
Next c
End Sub
Sub colorActiveCells()
Dim r, c As Long
For r = 2 To uExpEntryDlg.iGrid1.RowCount Step 2
For c = 2 To uExpEntryDlg.iGrid1.ColCount Step 2
uExpEntryDlg.iGrid1.CellBackColor(r, c) = g_PaleYellowColor
Next c
Next r
End Sub
1 15132391
2 AAAA 11389944
3 15132391
4 AAAA 11389944
5 15132391
An Image of the output grid is attached
screen.docx
(36kb) downloaded 65 time(s).