Reputation: 185
I have a data collection that holds a list of companies' data. Some companies have more than one office. I want to use windows form's datagridview to represent the data like this:
|--Company Name--|--Company ID--|--Company Address--|
| Alpha | 001 | 1 Alpha road |
|--Office Name---|--Office Address--|
| London Office | 1 London road |
| New York office| 1 New York road |
| Beta | 002 | 1 Beta Road |
|--Office Name---|--Office Address--|
| LA Office | 1 LA road |
| Paris Office | 1 Paris road |
I want a company's offices displayed as a child datagridview inside the parent datagridview . I found many solutions in ASP.net, but none in winform. Is there any way to achieve this?
Upvotes: 1
Views: 3333
Reputation: 565
Not 100% sure this would work, but maybe try something like this?
DataGridView dgv = new DataGridView();
grid.Controls.Add(dgv);
dgv.Location = grid.GetCellDisplayRectangle(ColumnIndex, RowIndex, true).Location;
dgv.Size = grid.GetCellDisplayRectangle(ColumnIndex, RowIndex, true).Size;
Upvotes: 2