I have a form with some textboxes and a datagrid.
I have two tables in my database: 'testdata' and 'history'
'testdata' is my parenttable, 'history' child... I've made the relation like this:
System.Data.
DataRelation dr2;System.Data.DataColumn colHeaderT;
System.Data.DataColumn colTest;
colHeaderT = ds.Tables[
"TestData"].DefaultView.Table.Columns["Lognr"];colTest = ds.Tables["History"].DefaultView.Table.Columns["Lognr"];
dr2 = new System.Data.DataRelation("RelHistTest", colHeaderT, colTest, false);
ds.Relations.Add(dr2);
dataGridViewHistory.DataSource = ds.Tables[
"TestData"].DefaultView;dataGridViewHistory.DataMember = "relHistTest";
In the grid, everything looks great.
The problem is that I want to show a cell from the first row of the grid in a textbox.
When I do it like this:
textBoxExtraDescription.DataBindings.Add(
"Text", ds.Tables["TestDataHistTest"].DefaultView, "Extra description");it looks good, but then I noticed that my datarelations is not working, the textboxtext doesn't change with the datagrid (grid works great and changes)
So the question is: how do I bind to a textbox with datarelations
All help is welcome! Thanks!

Databinding - datarelations - textbox
Niranjan Arikela
Thanks for the answer, but it doesn't work...
I've tried this, but than it get an error saying that the child list voor TestDataHistTest could not be created
textBoxExtraDescription.DataBindings.Add("Text", ds, "TestDataHistTest.RelHistTest.ExtraDescription")
when I do this:
textBoxExtraDescription.DataBindings.Add("Text", ds, "TestData.RelHistTest.ExtraDescription")
it works but still the text in the textbox doesn't change when the grid changes....
But thanks for trying and for the quick reply!
M1ckx
Just a guess... What if to bind your TextBox this way :
textBoxExtraDescription.DataBindings.Add("Text", ds, "TestDataHistTest.RelHistTest.ExtraDescription")
where "ExtraDescription" is the name of a field. If it consists of two words then I think it should be enclosed in square brackets.
lloydcodrington
I've solved it with:
textBoxExtraDescription.DataBindings.Add(
"Text", ds.Tables["TestData"].DefaultView, "RelHistTest.Extra description");Thanks for the help!