我的問題已解決。沒有內置屬性可用於設置標題的背景顏色。我不得不使用DrawFilter接口。
你可以從這個link找到有關此接口的詳細信息:
你應該創建一個實現IUIElementDrawFilter類。 在接口的GetPhasesToFilter方法中,檢查元素是否爲CardCaptionUIElement,以及是否返回其BeforeDrawBackColor階段。然後在DrawElement方法中,可以使用drawParams參數的DrawBackColor方法繪製背景。
然後,爲ultragrid設置drawfilter。
UltraGrid1.DrawFilter = New CustomDrawFilter()
Class CustomDrawFilter : Implements IUIElementDrawFilter
Public Function DrawElement(drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement
Dim row = DirectCast(drawParams.Element.GetContext(), UltraGridRow)
If (row.VisibleIndex Mod 2 = 0 And row.Selected = False) Then
drawParams.AppearanceData.BackColor = Color.Red
drawParams.DrawBackColor(drawParams.Element.RectInsideBorders)
Return True
End If
Return False
End Function
Public Function GetPhasesToFilter(ByRef drawParams As UIElementDrawParams) As DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter
If (TypeOf (drawParams.Element) Is CardCaptionUIElement) Then
Return DrawPhase.BeforeDrawBackColor
Else
Return DrawPhase.None
End If
End Function
End Class