Apply color to codejock grid column headers
From DataFlex Wiki
Jump to navigationJump to search
Sometimes you might want to color your grid column header. This is not natively supported via the DataFlex wrapper for the codejock grids.
You can however get this by using the following code:
// In the cCjDbGrid
Procedure OnCreate
Handle hoMarkUpContext
Variant vMarkUpContext
String sMarkup
Handle hoReportColumns
Handle hoReportColumn
Integer iCols
Integer iDisplayIndex
Integer iMyColumn
Variant vCol
Forward Send OnCreate
// As we use markup, we have to enable it and do so early on
Set ComEnableMarkup to True
// Color one column header yellow
Get phoReportColumns to hoReportColumns
Get phoReportColumn to hoReportColumn
Get ComCount of hoReportColumns to iCols
Move 1 to iMyColumn
For iDisplayIndex from 0 to (iCols-1)
Get ComColumn of hoReportColumns iDisplayIndex to vCol
If (iDisplayIndex=iMyColumn) Begin
Set pvComObject of hoReportColumn to vCol
Move "<Border xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>" to sMarkup
Append sMarkup " <Border.Background> "
Append sMarkup ' <LinearGradientBrush StartPoint="0, 0" EndPoint="1,0">'
Append sMarkup ' <GradientStop Color="Yellow" Offset="0"/>'
Append sMarkup " </LinearGradientBrush> "
Append sMarkup " </Border.Background>"
Append sMarkup ' <TextBlock Name="Sent" HorizontalAlignment="Left" Cursor="Hand">Sent items</TextBlock>'
Append sMarkup "</Border>"
Set ComCaption of hoReportColumn to sMarkup
End
Loop
End_Procedure