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
580
Add columns at runtime
posted

I need to use a custom class which returns a generic.list object.  I can make it the datasource and get it to display great.  I would like to manipulate the columns (add, hide, etc) at runtime.  I seem to either be putting the wrong keywords in the search or something.  FYI, I am a nubee to Infragistics toolset.

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    You could use an UltraDataSource, as Alex suggests. But there's nothing wrong with a generic list of objects. Just be aware that a List is not a really robust interface and it's not reall intended for data binding. The DotNet BindingManager won't be able to add new items to a List, so you won't be able to use the AddNew row in the grid. Nor will it send notifications to the grid when values in the list change in code - not through the grid. The UltraDataSource would solve all of these problems for you. Another option would be to use a generic BindingList instead of a List.

    Either way, you can add unbound columns to the grid usng the add method on the Band. And you can also hide columns using the Hidden property (as Alex mentions above).

    One thing I would recommend, though, is that you use the InitializeLayout event for all of this. The event fires any time the grid's DataSource changes, so it's designed to allow you to set up your layout.

Children