Create Master/Detail Datagrids at runtime using WINFORMS -- How to?

M

Mike

First I need to do this in a WINDOWS APPLICATION. Just trying to save you ASP
people some time....


Let's say we have two tables:

EMPLOYEES CITIES
--------- ------
SSID* City*
Name
City


There is a foregin key relationship between City in each table. I've created a
dataset that contains the above information, and everything cascasdes nicely. I
can delete a city, and the Dataset will cascade delete all the employees in that
city. Life is good.

I need to be able to create a GUI for this using Datagrids. Something like


dgCITIES dgEmployees
------------- --------------
1
2
3


When I click on a specfic row, I want to see all the employees for that city.

Assuming I have a strongly typed dataset, I know I can use the following for the
Datasrouce(s).

myDataset.Cities
myDataset.Employees

How do I show the master/detail relationship for these datagrids? I need to do
this at RUNTIME, I cannot do it at design time.


Thanks in advance,

-Mike
 
D

Dmitriy Lapshin [C# / .NET MVP]

Mike,

You can just bind your datagrid to the dataset itself. The grid should
recognize the relation between the tables and let you expand parent rows to
see corresponding childs. However, the layout won't be similar to that
you've sketched, it would be rather like this:

[+] New York
[+] Prague
[+] London

and when any row is expanded, a set of child rows will be displayed.
 
M

Mike

Unfortunatly, I can't use that layout. I need row to row(s)


Dmitriy Lapshin [C# / .NET said:
Mike,

You can just bind your datagrid to the dataset itself. The grid should
recognize the relation between the tables and let you expand parent rows to
see corresponding childs. However, the layout won't be similar to that
you've sketched, it would be rather like this:

[+] New York
[+] Prague
[+] London

and when any row is expanded, a set of child rows will be displayed.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Mike said:
First I need to do this in a WINDOWS APPLICATION. Just trying to save you ASP
people some time....


Let's say we have two tables:

EMPLOYEES CITIES
--------- ------
SSID* City*
Name
City


There is a foregin key relationship between City in each table. I've created a
dataset that contains the above information, and everything cascasdes nicely. I
can delete a city, and the Dataset will cascade delete all the employees in that
city. Life is good.

I need to be able to create a GUI for this using Datagrids. Something like


dgCITIES dgEmployees
------------- --------------
1
2
3


When I click on a specfic row, I want to see all the employees for that city.

Assuming I have a strongly typed dataset, I know I can use the following for the
Datasrouce(s).

myDataset.Cities
myDataset.Employees

How do I show the master/detail relationship for these datagrids? I need to do
this at RUNTIME, I cannot do it at design time.


Thanks in advance,

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top