I have a model we use on the UI that ends up in several grids (sometimes as a child-band of some other data). We have some properties that we've marked [Browsable(false)] since we don't need to show them but need to have available for conditional formatting we do in InitializeRow.
There's one grid, however, where we do want to show these columns. Is there a way to show a [Browsable(false)] columns in the grid? I thought I'd try setting the Hidden property to false on that column, but it isn't in the collection of columns to begin with so I ended up getting key not found exceptions.
Is removing the attribute and manually hiding those columns in the other grids the best and/or only solution?
Hi Jeffrey,
The grid doesn't get the column structure directly from your data source, it uses the DotNet BindingManager. It is the BindingManager that hides Browsable(false) properties. It simply does not return those columns from the GetProperties call. So the grid has no way to get this column as long as that attribute is on there.
There are a couple of approaches you can take:
1) You can remove the Browsable(false) from the data source column and then hide the column in every other grid.
2) You could leave the column hidden and then show the data in the one grid using an unbound column. If you are only displaying (and not editing) the data, then this is very easy. You just add the unbound column in the InitializeLayout event and populate it in the InitializeRow event (where you get the data using the row's ListObject). If the data needs to be editable, it gets a bit more complex, since you also have to write the users changes back to the ListObject. You can probably do this in the BeforeCellUpdate event.
Thanks for the quick reply. Luckily these columns aren't editable, so the second option will work great (and keep us from having to make changes in multiple places). Thanks!