473,545 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource: Change DataMember Assignment at Runtime?

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.DataSour ce = myBindingSource .
myBindingSource .DataSource = myDataSet
myBindingSource .DataMember = myDataSet.Table 1

**OR**

myBindingSource .DataMember = myDataSet.Table 2

Nov 9 '07 #1
1 8951
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(t rue);

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.DataSour ce = myBindingSource .
myBindingSource .DataSource = myDataSet
myBindingSource .DataMember = myDataSet.Table 1

**OR**

myBindingSource .DataMember = myDataSet.Table 2
Nov 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3909
by: silesius | last post by:
Hi All, I have two pagetabs. One pagetab is used to display a parent record and the other is suppose to display 3 related child records from another table. I can display the parent records just fine by using the bindingSource and a tableAdapter to fill the dataset. I'm having a problem displaying the 3 related records on the other pagetab....
1
12152
by: Leonardo | last post by:
Hi. I'm trying to build my first application with database access using VB 2005. I'm a VB 6 programmer and learning everything again has been challenging. I managed to write a code using some tips from a book I recently bought. The navigation works fine. My problem starts when it comes to adding new registers. I have three tables: clients,...
0
1548
by: uwe.braunholz | last post by:
Hello, I want to enable/disable some Textboxes by a property of a derived BindingSource-class. This is what i got so far: ---- class myBindingSource : BindingSource { public object mxtest = false; public EventHandler testChanged;
4
16719
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part I: I found the ValueType field, leading me to believe that I could say dataGridView.Columns.ValueType = typeof(Double);...
2
3300
by: =?Utf-8?B?TU1TSkVE?= | last post by:
How to let user delete multi rows from the BindingSource I have in my program datagridview bound it to sql table Throw Bindingsource To fill it: MyTableTableAdaptor.fill(MyDataset.Mytable); MyTableBindingSource.datasource = MyDataset;
1
3572
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I used the Data Sources window to drop a custom object onto the designer surface. It created a BindingSource and BindingNavigator as a result. When I open the Properties window on the BindingSource, I see DataSource property set to the object I created.
0
3590
by: newcooler | last post by:
I have a junction table for instance 1 service can have many contacts - using a composite key junction table. what i want to do is to filter all the contacts that belong to the service using the junction table that includes just PK to service and PK to contact as a composite key. I used this code 'set up the agency binding source ...
1
12131
by: =?Utf-8?B?Rm9lZg==?= | last post by:
I have a BindingSource with an underlying table with two primary keys. To set the position with one primary key works fine as shown in the code snippet below: Dim index As Integer = myBindingSource.Find("ColumnName", myColumnName) If (index <-1) Then myBindingSource.Position = index End If How should I set the BindingSource.Position...
2
4646
by: TamusJRoyce | last post by:
I am working on a group project where I do not have access to a BindingSource that is being passed through a function. The BindingSource's DataSource is set to a custom IBindingListView Collection. When I try to set IsNew on the BindingSource having the custom IBindingListView, the BindingSource IsNew remaines false. I have been able to do...
0
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.