Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Not bindable properties in grid
posted
Hello. I'm binding all my application's grids to lists of objects. When I do this, the wizard creates a bindingsource for my class, that's ok. But there are some properties that I dont' want to appear in the grid. All my objects derive from a base "clsEntity" class that defines some public properties to be used internally by the application, such as "modified", "deleted", "active", and so on... When I run the wizard all these columns are auto-added to the layout, but I don't want them there. I know i can hide them, but that represents an extra work that I would like to avoid. In addition, if I modify a class that was already in a finished form's grid, and create a new property, this new property automatically appears in the grid, making me check all the application's forms again to "hide" it if it's not intended to be shown. Is there any way to tell UltraWinGrid to avoid some properties from my classes? I've tried to define the property with the attribute "Bindable(false)" but that didn't work... any suggestion?? Thanks in advance.
Parents
No Data
Reply
  • 469350
    Offline posted

    The grid creates a column for every field exposed by the DotNet BindingManager. There is no way to remove a column from the grid that the BindingManager exposes. You can only hide columns.

    You have a few options, though. 

    1. Implement ITypedList on your classes and implement GetPropertyDescriptors to return only the properties you want exposed to the grid. The advantage of this approach is that it will work for any bound controls, not just the grid.
    2. Use an UltraDataSource as the data source for your grid in on-demand mode. So the UltraDataSource acts as a sort've intermediary between the grid and the "real" data source.
    3. Use the InitializeLayout event of the grid to loop through the column and hide all columns except the ones you want.
    4. Use UltraWinTree, instead of UltraWinGrid. The tree does have the ability to remove column - you can define a ColumnSet with only the columns you want to include. The down side of this approach is that the tree lacks some features of the grid such as filtering and summaries. 
Children
No Data