Dbuchan,
I have changed an older sample from me what was terrible quick and dirty.
Although this has maybe as well some errors, is it in my opinion better to
understand. The first part is only building of the tables.
'\\datagrid sample with combobox outside
'needs a datagrid, a combobox and two buttons on a form
'to start do the button create ds and cancel and a dataset will be created
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New DataSet("Test")
Dim dtName As New DataTable("Names")
Dim dcIdName As New DataColumn("IdName")
Dim dcName As New DataColumn("Name")
Dim dcCountryN As New DataColumn("Country")
dtName.Columns.Add(dcIdName)
dtName.Columns.Add(dcName)
dtName.Columns.Add(dcCountryN)
ds.Tables.Add(dtName)
dtName.LoadDataRow(New Object() {"0", "Herfried K. Wagner", "Austria"},
True)
dtName.LoadDataRow(New Object() {"1", "Cor Ligthert", "Holland"},
True)
dtName.LoadDataRow(New Object() {"2", "Armin Zingler", "Germany"},
True)
dtName.LoadDataRow(New Object() {"3", "Ken Tucker", "Florida"},
True)
dtName.LoadDataRow(New Object() {"4", "Jay B. Harlow", "New York"},
True)
dtName.LoadDataRow(New Object() {"5", "Terry Burns", "England"},
True)
Dim dtCountry As New DataTable("Countries")
dtCountry.Columns.Add("Country")
dtCountry.Columns.Add("IdCountry")
dtCountry.LoadDataRow(New Object() {"0", "Austria"}, True)
dtCountry.LoadDataRow(New Object() {"1", "Germany"}, True)
dtCountry.LoadDataRow(New Object() {"2", "Holland"}, True)
dtCountry.LoadDataRow(New Object() {"3", "Georgia"}, True)
dtCountry.LoadDataRow(New Object() {"4", "Florida"}, True)
dtCountry.LoadDataRow(New Object() {"5", "England"}, True)
ds.Tables.Add(dtCountry)
Dim dv As DataView = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
ComboBox1.DataSource = ds.Tables(1).DefaultView
ComboBox1.ValueMember = "IdCountry"
ComboBox1.DisplayMember = "Country"
ComboBox1.DataBindings.Add(New Binding("SelectedValue", dv,
"Country"))
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
Me.BindingContext(DataGrid1.DataSource).EndCurrent Edit()
End Sub
End Class
///
I hope this helps a little bit?
Cor