Binded textbox not allow to loss focus in vb.net

To solve bounded Textbox validating problem in vb.net with WCF Dataset, Follow the following steps..

  1. Drag and Drop field from DataSource window’s Dataset(ServiceReference Dataset) and put on form.
  2. Remove Binding source from Property window as show in following sanapshort.

bindingSorce-remove

3. Assign binding source to control that now allowing to remove focus while it is empty

”’ <summary>
”’ Bind textbox with binding source
”’ Specially need to remove focus when no input is enter then allow to change focus
”’ </summary>
Private Sub bindControl()

‘ Binding source is already assign then need to remove and set new binding source

Me.txtDate.DataBindings.Clear()
Me.txtNDItem.DataBindings.Clear()
Me.txtDItem.DataBindings.Clear()

Me.txtDate.DataBindings.Add(New System.Windows.Forms.Binding(“Text”, Me.D01101BindingSource, “ENDDT“, True, DataSourceUpdateMode.OnValidation, “”))
Me.txtNDItem.DataBindings.Add(New System.Windows.Forms.Binding(“Text”, Me.D01101BindingSource, “QLITEM“, True, DataSourceUpdateMode.OnValidation, “”))
Me.txtDItem.DataBindings.Add(New System.Windows.Forms.Binding(“Text”, Me.D01101BindingSource, “DPITEM“, True, DataSourceUpdateMode.OnValidation, “”))

End Sub

(Note:

Aqua color indicate Control name,Red Color indicate binding source of all bounded control and Purple color indicate Data table field that need to bind with textbox)

)

4. Call bindControl() method before fill Binding Source(EX:D01101BindingSource)

I Hope this will solve your problem……

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s