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
900
Adding and removing columns at runtime
posted

Hi,

I have an ultragrid with 2 bound columns on it.  I want to be able to create and remove columns at runtime.

When an event fires in my application, I need to refresh the grid's columns.  I want to delete all the unbound columns from my grid, and then add in columns again.  The columns are being added to an UltraGridGroup when they are created, by setting

column.Group = grid.DisplayLayout.Bands(0).Groups("grpName")

 

I tried using

grid.DisplayLayout.Bands(0).Columns.ClearUnbound()

but that doesn't seem to work correctly.  It looks like they are being deleted, but maybe the Group is holding on to them (???).  When I try to add the columns back in, I get an error that the Key already exists when I try to set the column.Group again.  My column keys are unique, so I don't know what's wrong.

Any thoughts?

Thanks,

~Karen

Parents
  • 37774
    posted

     Karen,

    If your columns are bound, then by definition they are owned and controlled by the underlying data source, which is why calling ClearUnbound() is not doing anything.  It's hard to say what's going on with your errors here, but if you want to actually *remove* a bound column, it would have to be removed from the data source.  Should you want to maintain the data source structure, you could simply set the column's Hidden property to true.

    -Matt

Reply Children