How to bind WinForm text field to update in TextChanged instead of LostFocus

I am attaching a text field to an object property and would like the property to be updated in the TextChanged event, and not in the case of the default LostFocus event. How to do it?

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

+3
source share
2 answers

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
+2
source

Source: https://habr.com/ru/post/1716547/


All Articles