【问题标题】:How to bind a WinForm textbox to update on TextChanged instead of LostFocus如何绑定 WinForm 文本框以更新 TextChanged 而不是 LostFocus
【发布时间】:2009-09-01 03:36:43
【问题描述】:

我正在将文本框绑定到对象的属性,并且希望在 TextChanged 事件而不是默认的 LostFocus 事件上更新该属性。这将如何实现?

如果 Binding 对象上有一个属性来指定应该使用哪个事件,那就太好了。

【问题讨论】:

    标签: .net winforms data-binding


    【解决方案1】:

    【讨论】:

    • 这就是我要找的东西!
    【解决方案2】:

    我创建了自己的 Binding 类来封装这种行为。

    Imports System.Windows.Forms
    
    Public Class ObjectBinding
        Inherits Binding
    
        Public Sub New(ByVal propertyName As String, ByVal dataSource As Object, ByVal dataMember As String)
            MyBase.New(propertyName, dataSource, dataMember)
            MyBase.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged
        End Sub
    
    End Class
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      相关资源
      最近更新 更多