DataGridView

G

Goh

Hi,

As we all know that Asp.net allo DataGridView inside another
DataGridView. How can we implement this kind of thing in Win Form.

Thanks.
Goh
 
L

Linda Liu [MSFT]

Hi Goh,

Thank you for posting.

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.



Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
L

Linda Liu [MSFT]

Hi Goh,

The DataGridView in Win forms doesn't support this scenario. We couldn't
put a DataGridView into another DataGridView.

Could you tell me why you would like to do like that? Do you want to use
two DataGridViews(e.g dgv1 and dgv2) to display the records of two
tables(e.g table1 and table2) which have a one-many relationship? If so,
you could display the records of table1 in dgv1. When you click one row in
dgv1, display the corresponding rows of table2 in dgv2.

Hope this helps.
If you have any cocerns, please don't hesitate to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
L

Linda Liu [MSFT]

Hi Goh,

If you want to display the records of two tables which have a parent/child
relationship in a Windows form, you could use two DataGridView controls to
show the records of the two tables respectively.

The main steps of creating a master/detail form using two DataGridView
controls is listed below.
1. Create a DataSet which involves the two datatables(e.g tableParent and
tableChild) and add a DataRelation(e.g relation1) of the two datatables in
the DataSet

2. Add a instance of the DataSet (e.g dataset1) and two BindingSource
instances(e.g parentBindingSource and childBindingSource) into your form

3. Use the statements to set the DataSource and DataMember of the two
BindingSource instances:
parentBindingSource.DataSource = dataset1;
parentBindingSource.DataMember = "tableParent";

childBindingSource.DataSource = parenBindingSource;
childBindingSource.DataMember = "relation1";

For more information, you may refer to the following link:

http://msdn2.microsoft.com/en-us/library/y8c0cxey(d=ide).aspx

Hope this helps.
If you have anything unclear, please don't hesitate to let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 

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