473,803 Members | 2,909 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 9677
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
9599
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
9688
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
14209
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
1482
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
1113
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
1256
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
8541
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
13651
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
9699
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
9562
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
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
10309
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10289
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7600
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
6840
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
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

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.