Hi,
I am binding a list of objects to a wingrid. My objects have two child collections of their own. These are both shown as a separate band in the grid.
Is it possible to ignore a child collection, so it doesn't appear in the grid?
grid.DisplayLayout.MaxBandDepth = 1
That won't do the trick, since it is a recursive object model:
List of A contains a List of A and a List of B, and so on.
I only want to see the lists of A.
Because of this recursive model, my Max. # of bands is unknown.
This is a tricky one. You could loop through all of the bands in the grid and check the Key of each band and set the hidden property on each band B. But this is probably not very efficient, since the bands will still exist (they will just be hidden, not removed) and it might not work, since the Bands collection might not contain all of the possible bands initially.
The most efficient thing to do would be to bind the grid to a data source that does not contain Band B at all. You could copy Band A's data to another DataSet.
What about adding [Browsable(false)] to the list of B property? I know it works for regular fields.
Adding a [Browsable(false)] attribute does the trick.
Must say I am a bit uncomfortable with putting "designer" attributes on my business objects only for the purpose of databinding.