BindingSource: Change DataMember Assignment at Runtime?

G

Guest

In the Visual Studio 2005 designer, I have a grid, a binding source, and a
data set which contains two data tables.

In the Designer, I make the settings below. If I set the DataMember for the
binding source to Table1, I see the data in Table 1. If I set the DataMember
for the binding source to Table2, I see the data in Table 2. This all works
great.

I need to be able to reassign the DataMember for the binding source at
run-time. If I assign it to the same table that's set in the designer, I see
data. If I assign the DataMember to the other table, I don't see any data in
the grid.

Has anybody successfully switched DataMember assignments for a Binding
Source at run-time? If so, is there something like refresh that I'm missing?

Thanks,
Randy




myGrid.DataSource = myBindingSource.
myBindingSource.DataSource = myDataSet
myBindingSource.DataMember = myDataSet.Table1

**OR**

myBindingSource.DataMember = myDataSet.Table2
 
G

Guest

I'll answer my own question. I'm using a third-party grid, and I needed to
use the following rebind command to refresh the binding between the grid and
the binding source after updating the binding source:

myGrid.Rebind(true);

Now I can switch between the data in either table at runtime.

Gee, I wonder if I can mark my own response as helpful...<ggg>

Randy
 

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