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
490
Adding a bound column to an UltraGrid at runtime
posted

Is it possible to add a bound column to an UltraGrid at runtime?  I am displaying a class (Class A) in the grid which has another class (Class B) as one of its properties.  The properties of Class B are not showing up as columns.  I would like to add the properties of Class B on the fly.  I have been able to do this in an unbound manner, but I need the data to come in.  What is the best way to add all of the properties of Class B as columns in the grid?

 

Thanks,

Steve

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Steve,

    The grid displays the data you give it in the schema you give it. So there's no way to move the bound columns up from the child object into the parent band in the grid.

    So there are two ways you can do this.

    1) You could add unbound columns to the parent band and use the InitializeRow event to populate those columns with the values from the child object. If these fields need to be editable, then you will only do this when the e.ReInitialize property is false, and then you will also need to handle or BeforeRowUpdate to update the child object from the data in the grid row.

    2) You could implement ITypedList on your class which contains the Class A objects and handle GetPropertyDescriptor and return custom PropertyDescriptors which translate Class B's properties into sort've simulated properties on Class A. This is a pretty advanced technique, but I am sure it can be done.

Children