TabControl & DataBinding

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

Now, I understand my problem (bugs?) about the Tab Control & dataBinding
1)a simple blank form with tabcontrol , there are 2 pages, pages1 got 3
textboxes (txtShipperNAme,txtJobNo,txtVslName) and one "New" button
2)As Formload, I will fill in the dsInvoice and bind the data
dsSeaExHBL.Clear()
daSeaExHBL.Fill(dsSeaExHBL, "BillLadingHeader")
bmSeaExHBL = Me.BindingContext(dsSeaExHBL, "BillLadingHeader")
Me.txtShipperName.DataBindings.Add("text", dsSeaExHBL,
"BillladingHeader.shippername")
Me.txtVslName.DataBindings.Add("text", dsSeaExHBL,
"BillladingHeader.vesselname")
Me.txtJobNo.Text = ""
3) in New button's click Event,
bmSeaExHBL.EndCurrentEdit()
bmSeaExHBL.AddNew()
4) I start to input the data , then I click the Tab Page2, and then I click
back Tab Page1.
5)Bugs:- txtShipperName & txtVslName 's Text got blank [It seems loss what I
input before]
6) For txtJobNo, the data still remain in TextBox.

What's wrong with Tab Control ???
Thanks
From Agnes
 
It should be a bug: Seems everytime back to page1 cause refreshing databind. Use following code to avoid the situation:

Private Sub txtVslName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVslName.TextChanged
bmSeaExHBL.EndCurrentEdit()
End Sub
 
Agnes,

I have tried to do your problem, see this sample and tell me after trying
that what is different with what you write and what is the problem or even
this sample solved your problem?.

I used a datatable that I made with one column however that is in my opinion
basicly not different from three columns.

Cor

'sample a form with on that a tabcontrol
'with two tabpages
'on tabpage 1 a textbox and a button
'on tabpage 2 a listbox
'and than pasted in
Private cma As CurrencyManager
Dim dt As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
dt = New DataTable
dt.Columns.Add("Name")
For i As Integer = 0 To 1
dt.Rows.Add(dt.NewRow)
Next
dt.Rows(0)(0) = "Agnes"
dt.Rows(1)(0) = "Marina"
'Before only to make a table
cma = CType(BindingContext(dt), CurrencyManager)
Me.TextBox1.DataBindings.Add("text", dt, "Name")
Me.ListBox1.DataSource = dt
Me.ListBox1.DisplayMember = "Name
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
cma.AddNew()
End Sub
 
Back
Top