473,811 Members | 3,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linking to datagrids together

How do i make it so that each time i select a different row in my
datagradview i want the data in my other to change accordingly.For
example, i will have invoices in the one grid and purchased items in
the other and when i select a invoice i want to bring up all the item
linked to the invoice
Jun 27 '08 #1
1 1145
You need to set exactly the same DataSource for each, and use DataMember
(on the second grid) to specify the property to use to obtain the
sub-data. This ensures that the same "currency manager" is used when
binding the outer items; here's a C# 3 example, but works the same in C#
2...

Marc

using System.Collecti ons.Generic;
using System.Windows. Forms;
class Foo
{
public string Name { get; set; }
List<Barbars = new List<Bar>();
public List<BarBars { get { return bars; } }
}
class Bar
{
public string Desc { get; set; }
}
static class Program
{
static void Main()
{
List<Foolist = new List<Foo{
new Foo {
Name = "Fred",
Bars = {
new Bar {Desc="abc"},
new Bar {Desc="def"}
}
}, new Foo {
Name = "Barney",
Bars = {
new Bar {Desc="ghi"}
}
}
};
Application.Ena bleVisualStyles ();
Application.Run
(
new Form
{
Width = 600,
Text = "Linked bindings",
Controls =
{
new DataGridView {
Dock = DockStyle.Fill,
DataSource = list,
DataMember = "Bars"
},
new DataGridView
{
Dock = DockStyle.Left,
DataSource = list
}

}
}
);
}
}
Jun 27 '08 #2

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

Similar topics

15
425
by: Rob Ratcliff | last post by:
I'm compiling the latest version of a CORBA ORB called MICO on a Cray X1. It makes heavy use of templates and namespaces. Up until the link step, the C++ source code compiled flawlessly. But, when it tried to link, I got the attached warnings and then an error. Any ideas why the linker wouldn't see the objects in the library? They look like pretty long names, so maybe there is some type of symbol length or mangling issue going on? The...
4
1462
by: Leon.Kemp | last post by:
I have a project that I am working on that will (ultimately) write to 2 Excel Spreadsheets, 3 Access databases, and communicates with 3 other programs (torque monitoring software, a laser rangefinder, and a specialized industrial inkjet printer). I had much of it working in VB6, but then upgraded (for reasons that I can no longer remember) to .NET. I am now having problems communicating to Access. The main form has 35 text boxes on it fo an...
0
1261
by: Scott Meddows | last post by:
I'm having trouble scrolling some datagrids so they sync up... I have two identical datagrids on a form, filled with eh same dataset. I want a user to be able to scroll on the datasets and the other dataset then scrolls to the same place on the other dataset (bare with me). This is the code that I have so far... Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load...
3
1339
by: anon | last post by:
I want to obtain the appearance of frozen columns as in an excel sheet so thet the first two columns of the table remain in view at all times. Example - I have a table of products - listed by Item and Line. I want the Item and Line columns to remain visible whilst being able to scroll the rest of the grid across to reveal other columns. Ialso need the information to be present and synchronised with the rows when I scroll down.
2
2456
by: Jim Johnson | last post by:
C++ linking works by using Linker to combine object files into single exe file. Does each .cpp file compile to a single .obj file? If the .cpp code called functions in some library (.lib) does the Linker will extract the required .obj object file from the library and link together with other .obj file to form a EXE? So the EXE file can be think of a code file that merged all the .cpp
0
9605
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
10651
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
10393
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...
0
9208
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
7671
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
6893
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
5556
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...
1
4342
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
3871
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.