Hi there,
Probably you have seen this question more than once, but this is really critical for our business now.
We have to buy a new set of controls to enrich our user experience. I have been testing with WinGrid, but it has a very specific problem: it autogenerates columns.
Our database generation tool automatically creates views of underlying tables, which makes it have a lot of columns (in some case above 250). I don't have the time to hide all those fields manually.
Is there a way to disable the auto generation of columns, like the DataGridView does?
Hi Patrick,
No, the UltraGrid always creates columns based on the data source you provide.
There are a number of ways you can deal with this:
1) Use the InitializeLayout event of the grid and hide the columns programmatically.
2) You could set up the grid layout at design-time and add in only the columns you want to see. Here's an article that shows you how.
HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?
3) The UltraWinTree control allows you to turn off the auto-generation of the columns. But it lacks certain grid features like filtering and summaries.
4) Use the UltraDataSource in the virtual mode as an intermediary between your "real" data source and the grid. The UltraDataSource allows you to work in an on-demand mode where it fires events when data is requested, updated, etc.
5) IIf you are using a custom data source, I'm pretty sure there is an attribute you can put on a field to hide it from the BindingManager. I'm not sure what the attribute is off the top of my head, but if you want to try this out, let me know and I will see if I can find out.
Hi Mike,
Thank you for your suggestions. I am not all satisfied with the options. Is there a way to make it easier to disable columns (like multiselect of rows in the designer, so I can edit the visible property at once)?
The business objects I use come from our own autogenerated O/R-mapping code, with an autogenerated database.
So when you have for example Projects as an entity, sometimes you just want so show the name with the customer of the project. Another time you had like to show the financial aspect of the project. These are all caught in one database view, which map to one entity on the .net code side. So a Browsable(false) property isn't an option.
Can you tell me something about the possibilities of above suggestion about designer optimalization?
Thanks,
Patrick
I'm not sure what you are asking. No matter how the data source gets generated, at some point, you have to know which columns to display in the grid. If you want to do this at design-time and then have the grid display only those columns you set up, thenyou probably want to go with option 2 in the list I gave you above.
I'm not sure where disabling columns or multiselection of rows comes into this.
I meant that I had like to be able to select more than one column in de grid's designer tool. When you for example can select all columns at once and change the required property that it solves a lot of my problems.
See for example the behaviour of the Windows Forms designer: select two labels and the property dialog shows all common properties. They can be edited at once, affecting both controls.
Do you get the point?
Yes, you can do that in the grid desiger. Click the Start button on the grid and go to the Band and Column Settings. Expand that, go to the band you want and select "Columns".
This gives you a list of columns and you can mutli-select and apply properties, just as you would in the form designer.