views:

400

answers:

2

I am binding a textbox to a property on an object, and would like the property to be updated on the TextChanged event and not the default LostFocus event. How would this be done?

It would be nice if there was a property on the Binding object to designate which event should be used.

+3  A: 

Try changing the Binding.DataSourceUpdateMode property to the DataSourceUpdateMode.OnPropertyChange.

Franci Penov
That's what I was looking for!
Bill
+1  A: 

I created my own Binding class to encapsulate this behavior.

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
Bill