DataBinding - Need a few tips...

  • Thread starter Vagabond Software
  • Start date
V

Vagabond Software

I am familiar with basic, brain-dead databinding, but I feel I need
something a little more complex for my current application. I would like a
few pointers or advice.

I have a main form with a DataGrid bound to a DataView object. I have a
custom control (DetailPanel), with a bunch of labels on it, that will
display all the details related to the row selected in the DataGrid.

How do I go about making sure the Labels on the DetailPanel display
information related to the row currently selected in the DataGrid?

I know how to create Binding objects on the DetailPanel that *should*
display the appropriate column of data in the appropriate Label (an
assumption at this point):

Dim bindText As New Binding("Text", Me.DataSource, "myTable.myColumn")
Label1.DataBindings.Add(bindText)

Now, what do I need to link the Main Form and the custom control? Do I need
a CurrencyManager? Two CurrencyManagers? Something else entirely?

Any help or direction is greatly appreciated.

Thanks,

Carl
 
B

Bart Mermuys

Hi,

Vagabond Software said:
I am familiar with basic, brain-dead databinding, but I feel I need
something a little more complex for my current application. I would like a
few pointers or advice.

I have a main form with a DataGrid bound to a DataView object. I have a
custom control (DetailPanel), with a bunch of labels on it, that will
display all the details related to the row selected in the DataGrid.

How do I go about making sure the Labels on the DetailPanel display
information related to the row currently selected in the DataGrid?

I know how to create Binding objects on the DetailPanel that *should*
display the appropriate column of data in the appropriate Label (an
assumption at this point):

Dim bindText As New Binding("Text", Me.DataSource, "myTable.myColumn")
Label1.DataBindings.Add(bindText)

Now, what do I need to link the Main Form and the custom control? Do I
need a CurrencyManager? Two CurrencyManagers? Something else entirely?

If you bind multiple Control's that have the same BindingContext(which is
the default for a Form and all of its Controls) to the same
DataSource/DataMember(excluding fieldname), then the same CurrencyManager
will be used and therefore they will navigate together.

So if you used a DataView as the DataSource for the DataGrid, then you need
to use the _same_ DataView as the DataSource for the TextBox's.

HTH,
Greetings
 

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