修改UltraDateTimeEditor后台

Modification of the UltraDateTimeEditor background

我需要将 Infragistics.Win.UltraWinEditors.UltraDateTimeEditor 的背景颜色设置为黄色,例如当时间不是今天时。此外,当我将光标移到编辑器上时,我需要显示一条警告消息。我知道XAML有这样的属性我可以用。在 winform 中怎么样?

关于如何实现目标的简单示例。我很确定还有其他方法可以完成此操作,但这行得通

' Globals controls and Forms
Dim f As Form
Dim dt As Infragistics.Win.UltraWinEditors.UltraDateTimeEditor 
Dim tt As Infragistics.Win.ToolTip 

' This Main has been built using LinqPAD, you could have problems 
' running it, as is in a WinForms project, but the concepts are the same
Sub Main()

    dt = New UltraDateTimeEditor()
    dt.Dock = DockStyle.Top

    ' Add the event handlers of interest to the UltraDateTimeEditor
    AddHandler dt.Validating, AddressOf onValidating
    AddHandler dt.Enter, AddressOf onEnter

    tt = New Infragistics.Win.ToolTip(dt)

    ' Just another control to trigger the OnEnter and Validating events
    Dim b = New Button()
    b.Dock = DockStyle.Bottom
    f = New Form()
    f.Size = New Size(500, 500)
    f.Controls.Add(dt)
    f.Controls.Add(b)
    f.Show()
End Sub

Sub onValidating(sender As Object , e As EventArgs)

    ' Some condtions to check and then set the backcolor as you wish
    dt.BackColor = Color.Yellow

End Sub

Sub onEnter(sender As Object, e As EventArgs)

    ' Set the background back    
    dt.BackColor = Color.White

    ' Some condition to check to display the tooltip
    If dt.DateTime <> DateTime.Today Then

        tt.ToolTipText = "Invalid date"

        ' Time to leave the message visible
        tt.AutoPopDelay = 2000
        tt.DisplayStyle = ToolTipDisplayStyle.BalloonTip

        ' Calculation to set the tooltip in the middle of the editor
        Dim p = New Point(dt.Left + 50, dt.Top + (dt.Height \ 2))
        p = dt.PointToScreen(p)

        ' Show the message....
        tt.Show(p)
    End If
End Sub