DisplayNested Structure Array in DataGridView

DisplayNested Structure Array in DataGridView

Post by Mark Jerd » Sat, 03 Mar 2007 05:07:03


VS 2005 SP1. Googled without success.

I have an array of structs, and some of the elements are arrays of structs.
E.g.,
-------------------------------------
public struct foobar {
public int ID;
public string Name;
public foo[] FooFields;
public bar[] BarFields;
}

public struct foo {
public int LengthMin;
public int LengthMax;
public string Name;
public byte[] ByteRay;
}

public struct bar {
public int ErrNum;
public string ErrName;
public string ErrDescription;
}

private foobar[] FooBarRay;
-------------------------------------

I'm trying to display the array in a DataGridView. I can get the data into
the DataGridView, I just can't figure out how to make it show up. This code
gets the data into dataGridView1

dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = FooBarRay;

but nothing is displayed.

What's a good way to display hierarchical structs like these? Am I missing
something about DataGridView? Is there a better control? Are there tools
for making the wrapper classes? Is there a way to load this array into some
part of ADO.NET and display? My googling on these topics didn't find
anything helpful, so far.

Thanks.

-- Mark
 
 
 

DisplayNested Structure Array in DataGridView

Post by Robin » Sat, 03 Mar 2007 10:50:31

The DataGridView does not handle heirarchical structures. They generally
advise us to use two grids, one for the parents and one for the children,
with a data relation between them. Otherwise, you'll have to get a 3rd
party component.

Robin S.
--------------------------