DataBinding when using child form question

  • Thread starter Thread starter Mika M
  • Start date Start date
M

Mika M

Hello!

My windows forms application contains TextBoxes for Master-table like ...
txtMyTextBox.DataBindings.Add(New Binding("Text", ds.Tables!Headers,
"MyField"))

.... and FlexGrid for child table like ....
_flexItems.SetDataBinding(ds.Tables!Headers, "Items")

.... and FlexGrid for child table's child table like ....
_flexDetails.SetDataBinding(ds.Tables!Headers, "Items.Details")

.... before all this created relation between tables like ...
ds.Relations.Add(New DataRelation("Items", ds.Tables!Headers.Columns!ID,
ds.Tables!Items.Columns!HeaderID))
ds.Relations.Add(New DataRelation("Details", ds.Tables!Items.Columns!ID,
ds.Tables!Details.Columns!ItemID))

.... and it's working fine, but I'm trying to make a separate form for
Details because Details are needed to edit only rarely, and to save some
space on the main form. I created new form for Details containing FlexGrid,
and OK- and Cancel-buttons. I don't know how to make editing Details-table
to work correctly in this new form? I tried something like this without
success ...

Private Sub mnuDetails_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuDetails.Click
Dim f As frmDetails = New frmDetails
f._flexDetails.SetDataBinding(ds.Tables!Headers, "Items.Details")
f.ShowDialog()
f.Dispose()
End Sub

It is always retrieving Detail rows containing same first used ItemID only
:-(
 
Private Sub mnuDetails_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuDetails.Click
Dim f As frmDetails = New frmDetails
f._flexDetails.SetDataBinding(ds.Tables!Headers, "Items.Details")
f.ShowDialog()
f.Dispose()
End Sub

Now I know what was reason for the problem, and I decided to answer by
myself :-)

f.BindingContext = me.BindingContext ' << missing line

-- Mika
 
Back
Top