PC Review


Reply
Thread Tools Rate Thread

BindingSource: Change DataMember Assignment at Runtime?

 
 
=?Utf-8?B?cmFuZHkxMjAw?=
Guest
Posts: n/a
 
      9th Nov 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?cmFuZHkxMjAw?=
Guest
Posts: n/a
 
      9th Nov 2007
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



"randy1200" wrote:

> 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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change BindingSource ConnectString at runtime Henrique Microsoft VB .NET 1 14th May 2010 02:32 PM
Connect to BindingSource with DataMember cold80 Microsoft ADO .NET 0 26th Apr 2008 07:15 PM
BindingSource set DataSource and DataMember atomically? Doug Crawford Microsoft Dot NET Compact Framework 0 19th Sep 2007 06:55 PM
Runtime field assignment in crystal report =?Utf-8?B?b3NoYWF0aA==?= Microsoft Dot NET 0 15th Jul 2004 11:49 AM
Problem with runtime recordsource assignment in subreport Savvoulidis Iordanis Microsoft Access Reports 1 9th Jul 2004 05:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 AM.