Click here to Skip to main content
11,932,103 members (60,901 online)
Rate this:
Please Sign up or sign in to vote.
See more: LINQ database DataGridView , +
I have a database containing two tables, Products and ProductLicences. ProductLicences.ProductID has a foreign key refereince to Products.ProductID.

How do I represent that relationship in a WinForms DataGridView?

When feeding the DtaaGridView (SQL Metal and through LINQ to SQL), the ProductLicences.ProductID, it automatically generates a column with a text field expecting a "Product" (which of course I can't enter...).

How do I change this column to contain a combobox listing the available products?
Posted 11-Feb-10 11:38am
Edited 13-Feb-10 4:54am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think if you create the relationship within the dataset, and put the dataset to the DataGrid's DataSource, it will automatically show you the relationship in the view.

DataRelation drelation = new DataRelation("RelationName", ds.Tables[0].Columns["Col1"], ds.Tables[1].Columns["Col2"]);

This will add a new datarelation between the Table0 and Table1 within the DataSet ds.

Wink | ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 13 Feb 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100