【问题标题】:Modification of the UltraDateTimeEditor backgroundUltraDateTimeEditor 背景的修改
【发布时间】:2015-10-29 18:17:10
【问题描述】:

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

【问题讨论】:

  • 尝试使用验证事件作为背景颜色,使用带有工具提示的回车事件
  • @Steve 谢谢你的回复。我了解验证事件。但是对于“带有消息工具提示的输入事件”,我没有得到它。你能详细解释一下吗?

标签: vb.net winforms controls infragistics


【解决方案1】:

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

' 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    相关资源
    最近更新 更多