473,830 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting a BindingNavigato r to a DataGridView bound to XML


I have generated an XmlDocument, then bound it to a DataGridView (thanks
to a pointer from PeterBromberg in a separate, recent posting). Now I want
to connect a BindingNavigato r, but my rudimentary attempt failed.

In the Visual Designer I added a BindingSource bs, then a BindingNavigato r
bn, and assigned bs to the BindingSource property of bn. In code, I
generate my XmlDocument, massage it to fit into a DataSet, then assign it
to the DataSource property of my DataGridView dgv. That all works.

I then tried setting bs.DataSource to dgv.DataSource and bs.DataMember to
dgv.DataMember. The only thing that did for me is provide a correct record
count in the Binding Navigator when executed. The only affect of the
navigation arrows is to alter the count in the BindingNavigato r--no
changes in the active row in the DataGridView occur. So clearly I am
missing one or more pieces...
Aug 22 '06 #1
3 9678
Hi Michael,

To alter the current row in the DataGridView when clicking the navigation
arrows of the BindingNavigato r, you should set the DataSource property of
the DataGridView to the BindingSource instance bs, rather than the dataset
instance.

Every data source has a BindingManagerB ase object associated with it. If a
data source is a list, we could change the Position property of
BindingManagerB ase object to change the current item in the data source.

The BindingManagerB ase objects associated with the BindingSource bs and the
dataset instance are not the same one. We could access the
BindingManagerB ase objects using the following code.

BindingManagerB ase bm1= bs.CurrencyMana ger;
BindingManagerB ase bm2 =this.BindingCo ntext[bs]; // bm1 == bm2
BindingManagerB ase bm = this.BindingCon text[this.dataSet11, "TableName"];
// bm1 <bm

When you set the BindingSource property of the BindingNavigato r to bs and
click the navigation arrows of the BindingNavigato r, BindingNavigato r
manipulates the BindingManagerB ase object associated with the
BindingSource. In this case, you should set the DataSource property of the
DataGridView to the BindingSource bs.

If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 23 '06 #2
I think you need to assign
bs.DataSource = (your new DataSet);
dgv.DataSource = bs;
i.e. tell dgv to use (for its data) the BindingSource data-source that
is bound to the navigator; otherwise they are independept.

Any use?

Marc

Aug 23 '06 #3
Thanks to both Linda (for supplying both the answer and the background)
and to Marc (for supplying the answer in a very concise format:-). I found
both useful.
Aug 23 '06 #4

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

Similar topics

2
9603
by: bds | last post by:
I'm new to .net 2.0 and I'm trying to figure out the best way to create a form that has a couple of controls and one of the controls is a combo box with a data bound list of items from another table. To understand the problem more, consider using the AdventureWorks2000 database. I want a simple form that shows FirstName, LastName, and Shift. Instead of the ShiftID, I want the shift name from the Shift table to be displayed. Here's...
2
9690
by: David Veeneman | last post by:
How can I set a bound DataGridView control to use a dataset table's column captions, instead of column names? I'm working with a DataGridView control, which I have bound to a table in a dataset. The dataset is created at run time, so I don't know column headers in advance. The table's column captions are set at run time, using the DataColumn.Caption property. The table is bound to the grid using the grid's DataSource property. Here is my...
5
14210
by: John | last post by:
Hi When I press the delete button on the BindingNavigator it deletes the record without any warning. How can I add a warning dialog when the delete button on the BindingNavigator is pressed and before the record is actually deleted? Thanks Regards
0
1486
by: Vico | last post by:
Hi! I have this scenario: I have a windows form. I have a DataGridView Control which is bound to a DataSource. Under the DataGridView I have texboxes which represent each one of the columns in the Datasource (also shown in the datagridview) As I move from row to row, the values of the textboxes (which are also bound to the datasource) change according to the value of each column of such row. That is perfectly normal.
0
1115
by: Chuck Gantz | last post by:
I have a child table (the "TestType" that is in my code below) that I am trying to bind to its parent ("Test" in the code. I've commented out that line below sice it doesn't fix my problem). The Test table is bound to a BindingNavigator. Everything displays ok. In other words, when I click the advance or back buttons of the navigator, the nameTextBox1 control shows the correct Test text, and the TestTypeControl (which is my user control)...
0
1258
by: Firoz | last post by:
Good day all, On my base form I have amongst others, a BindingNavigator/Datagridview control. I have changed the modifier properties for all the controls to "Protected Friend", but for the BindingNavigator/Datagridview I cannot change any properties in the new inherited form. All other controls are fine. Has anybody got any suggestions?
3
8542
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the following questions: 1. Can DataReader be bound DIRECTLY to DataGridView? 2. If DataReader cannot be bound directly to DataGridView, how can I load a DataReader into a DataTable and bind the DataTable to DataGridView? Can the DataTable be a...
12
13662
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid display in a textbox below the datgridview. I currently have it fixed so if you click on a row the note field from that row is put in the textbox. I'd like this to be automatic as they move through rows. Also the note field is one of two fields...
2
3115
by: GS | last post by:
I see in the design view of the binding navigator that the items like next Item, prev item... are enabled but when I run, the form, somehow they got disabled. I can still scroll thru the gridview by clicking on a row in the gridview, and use up/down cursor.key It seems to me some generated code turn of the scroll items etc in the binding navigator. and I have to explicitly in the form load event to enable each one.
0
9793
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10774
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10206
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9315
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5617
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.