BindingNavigator items won't work -
02-22-2007
, 01:11 PM
Hi All,
I've got a database with several tables in it. Each table has got the
same columns (name, type etc.)
On my form, I want to show the records of a selected table (selected
in a combobox) in corresponding textboxes. The bindingnavigator should
then allow you to move through the records, or should it not? Probably
not, because on my form it doesn't work!
Look at my code below:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add(CyclopsDataSet.TableA.TableNam e)
ComboBox1.Items.Add(CyclopsDataSet.TableB.TableNam e)
ComboBox1.Items.Add(CyclopsDataSet.TableC.TableNam e)
End Sub
Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.TextChanged
TextStartnr.DataBindings.Clear()
TextVoor.DataBindings.Clear()
TextAchter.DataBindings.Clear()
TextNatio.DataBindings.Clear()
TextType.DataBindings.Clear()
Select Case ComboBox1.Text
Case "TableA"
'bindingsource should be set. if this is [none] the
bindingnavigator is disabled
Me.BindingNavigator1.BindingSource = Me.BindingSource1
'setting the datamember which corresponds with the
selected table
BindingSource1.DataMember = "TableA"
'binding of columns with the textboxes
TextStartnr.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableA.Startnummer"))
TextVoor.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableA.Voornaam"))
TextAchter.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableA.Achternaam"))
TextNatio.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableA.Nationaliteit"))
TextType.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableA.Type"))
'filling the tableadapter
Me.TableATableAdapter.Fill(Me.CyclopsDataSet.Table A)
Case "TableB"
BindingSource1.DataMember = "TableB"
TextStartnr.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableB.Startnummer"))
TextVoor.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableB.Voornaam"))
TextAchter.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableB.Achternaam"))
TextNatio.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableB.Nationaliteit"))
TextType.DataBindings.Add(New Binding("Text",
CyclopsDataSet, "TableB.Typerenner"))
Me.TableBTableAdapter.Fill(Me.CyclopsDataSet.Table B)
Could someone please tell me what I'm doing wrong??
Thanx... |