Help with Advanced Datagrid binding

B

Brad Shook

I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the datagrid and need
it to hold the data for the current record selected in the datagrid.
Here is a part of the code.

'DataSetWellMobile1 is the dataset with all the data
'DGWellResults is the dtagrid I am binding the data to
'txtWellComments is the textbox that I need bound

Me.DataSetWellMobile1.Relations.Add( _
New DataRelation( _
relationName:="relWellInfo", _

parentColumn:=Me.DataSetWellMobile1.Tables("TblPeople").Columns("UniqueId"),
_

childColumn:=Me.DataSetWellMobile1.Tables("TblWellMobileInfo").Columns("PersonId"),
_
createConstraints:=True))

Me.DGWellResults.DataBindings.Add(New Binding("DataSource",
Me.DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo"))

Me.txtWellComments.DataBindings.Add(New Binding("Text",
DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo.Comments"))

The code binds everything but the currency manager does not change the
textbox to the next record when I select on the next record in the
datagrid.

What am I missing.
Thanks,
Brad
 
C

Cor Ligthert

Brad,

Maybe do I not understand you, however what you tell is simply to done using
this sample.

\\\Needs only one datagrid and a label on the form
Private dtVBreg As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
DataGrid2.DataSource = dtVBreg
Label1.DataBindings.Add("Text", dtVBreg, "Name")
End Sub
'only to create the table
Private Sub CreateTables()
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 6
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
I hope this helps?

Cor
 
B

Brad Shook

I think you understand what I need to do. This normaly would work but since
I am using a DataRelation it does not work.
Thanks,
Brad
 
C

Cor Ligthert

Brad,

I was thinking about however could not see that directly, before I do
something for nothing, you want to show from a child datagrid?

Cor
 
B

Brad Shook

Yes that is correct. If I navigate the parent datagrid the child changes
correctly. I just need to move one of the datacolumns from the child column
to seperate textbox.

Ex.
I navigate the parent DG and the Child changes correctly. I navigate the
child DG but the text box does not stay in sync with the selected record in
the child DG.

Does that make since?

Brad
 
C

Cor Ligthert

Brad,

I thought I did it once however that was another method.

I have the same problems as you. The currencymanager from the
relation.childtable seems to do nothing, I find this interesting will look
further, however have not direct an answer.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top