hello, i am not sure whether i am asking something trivial, but i got to ask !!
i usually assign the grid's datasource to a List<BusnsObjects>. So all the public properties of the business object are shown on the grid.
then in the Initializelayout method of the grid i usually do the following
1. Hide the columns that the user doesnot need to know
2. Also Exclude from column chooser some internal ID fields
But for Business Objects that have List of other objects as a part of them, when assigned to the grid will show the hierarchy.
What i want to do is make sure only the base properties are shown on the grid(also on the column chooser) ?
say when i double click on the row i could show a usercontrol containing the complete details.
Chethan Shetty said:What i want to do is make sure only the base properties are shown on the grid(also on the column chooser) ?
If you mean you only want to show the root-level and not show any child bands, then all you have to do is set grid.DisplayLayout.ViewStyle to SingleBand.
If you put an attribute [Browsable(false)] on your properties you don't want to show, they will be hidden.
If you don't want to do that, bind the grid to the object type in design time and set the hidden property of each column you don't want to see. To do that:
1. In the grid properties window open the dropdown of "DataSource".
2. Select "Add Project Data Source...".
3. In the dialog select "Object" and "Next"
4. Find your object type and select it.
5. Open the grid designer (Click on "Start!" in the buttom), go to "Band and Column Settings", Select each row you want to hide and set Hidden to true, or use the "Column Arangement Overview".
I think that the column chooser know to hide hidden columns, but if it doesn't work, you can set column.ExcludeFromColumnChooser to true.
If you want to show only the first band:
grid.DisplayLayout.ViewStyle = ViewStyle.SingleBand
If you want to know what is the object that being shown on the double clicked row, use the DoubleClickRow event. Each row has a ListObject property.