>>> Sub BindingFormat() Implements IControlBindingFormat.BindingFormat >>> Dim B As Binding = Me.DataBindings.Item(0) >>> AddHandler B.Format, AddressOf BooleanToJaNeen >>> AddHandler B.Parse, AddressOf JaneenToBoolean >>> End Sub >>> Sub BooleanToJaNeen(ByVal sender As Object, ByVal cEvent As ConvertEventArgs) >>> If cEvent.Value Is System.DBNull.Value Then >>> cEvent.Value = "" >>> Exit Sub >>> End If >>> cEvent.Value = IIf(cEvent.Value, "Ja", "Neen") >>> End Sub >>> Sub JaneenToBoolean(ByVal sender As Object, ByVal cEvent As ConvertEventArgs) >>> cEvent.Value = IIf(cEvent.Value = "Ja", True, False) >>> End Sub >>>>>
Imports System.ComponentModel Public Class Form1 Inherits System.Windows.Forms.Form Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Private m_isItTrue As Boolean Public Property IsItTrue() As Boolean Get System.Diagnostics.Trace.WriteLine("Getting :" + m_isItTrue.ToString()) Return m_isItTrue End Get Set(ByVal value As Boolean) System.Diagnostics.Trace.WriteLine("Setting :" + value.ToString()) m_isItTrue = value End Set End Property Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TextBox1 = New System.Windows.Forms.TextBox() TextBox1.Location = New System.Drawing.Point(100, 100) TextBox1.Size = New System.Drawing.Size(100, 20) TextBox1.CausesValidation = True Me.Controls.Add(TextBox1) Dim B As Binding = New Binding("Text", Me, "IsItTrue") AddHandler B.Format, AddressOf BooleanToJaNeen AddHandler B.Parse, AddressOf JaneenToBoolean TextBox1.DataBindings.Add(B) Me.Controls.Add(New Button) 'Just to allow focus to move End Sub Private Sub HandleValidating(ByVal sender As Object, ByVal e As CancelEventArgs) Handles TextBox1.Validating System.Diagnostics.Trace.WriteLine("Validating") End Sub Private Sub HandleValidated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Validated System.Diagnostics.Trace.WriteLine("Validated") End Sub Sub BooleanToJaNeen(ByVal sender As Object, ByVal cEvent As ConvertEventArgs) If cEvent.Value Is System.DBNull.Value Then cEvent.Value = "" Exit Sub End If cEvent.Value = IIf(cEvent.Value, "Ja", "Neen") System.Diagnostics.Trace.WriteLine("Format to: " + cEvent.Value.ToString()) End Sub Sub JaneenToBoolean(ByVal sender As Object, ByVal cEvent As ConvertEventArgs) cEvent.Value = IIf(cEvent.Value = "Ja", True, False) System.Diagnostics.Trace.WriteLine("Parse to: " + cEvent.Value.ToString()) End Sub End ClassTry running this and check the Output window. Where does your form behaviour differ ?