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
335
Column lost when I use SetDataBinding second time.
posted

 

Hi,

I add two columns in ultragrid named "COL1","COL2" when form Load, and then I binding a datatable dt with only one column named "COL1" ,and SetDataBinding(dt, Nothing, True).  at that time the grid showed data perfectly. and then I create another datatable dt2 with only one column name "COL2", and SetDataBinding(dt2, Nothing, True). Unfortunately, the grid lost the COL1, Why? How to always keep the columns that defined in the Form Load

I use win7/.NET 2010/Vol2013.1

Cheers!

  • 469350
    Offline posted

    This won't work. The grid can't maintain the data structure once you bind it more than once at run-time. When you bind the grid at run-time, it tries to maintain the data structure from design-time, but it marks the design-time structure specially for this purpose. You can't do it at run-time.

    If you want to have unbound columns in the grid like this, then I recommend using the InitializeLayout. Examine the existing columns and then add unbound columns for any extra columns you want that are not in the data source.