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
20
UltraGrid binded to SortedSet<T> issues
posted

Hello,

Yesterday I faced very strange problem with the UltraGrid.

In my application ug.DataSource is defined via BindingSource object. After that BindingSource object is being updated after user clicks something on a screen.

The UltraGrid itself if set up to show list of objects of type T which for example has property First, Last, Phone, and the grid is set to show only Phone in the grid; the rest of the properties are hidden.

Now the problem is that when I pass empty SortedSet<T> to the BindingSource the grid starts showing Count, Min, Max columns (which are properties of the SortedSet, not the T). If after that I pass non-empty SortedSet<T> it shows me all properties as columns ignoring the settings I set.

But if I convert my SortedSet<T> to List<T> before assignment then everything is fine, and doesn't matter empty or not it will show Phone column only all the time.

Please let me know if somebody saw something like this before and what may cause this issue.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The way the grid gets the Columns and Bands from the data source is by asking the DotNet BindingManager. The BindingManager gets the data structure from the ITypedList interface.

    But if you are using a DataSource that does not implement ITypedList, then the BindingManager will determine the data structure using the first item in the list.

    If there are no items in the list, the BindingManager will try to add a new item to the list and the get the properties from that item, and then cancel the add.It does this via the IEditableObject interface (or possibly the ICancelAddNew interface.

    I took a look at the SortedSet<T> class and it does not support any of these interfaces. So if you are using an empty SortedSet, there is no way for the BindingManager to get the column structure.

    Sometimes the BindingSource object will add extra support for determining the data structure if the actual data source does not, but I guess the BindingSource doesn't have support for the SortedSet class.

    So it seems that if you need to bind the grid to an empty list, you will need to use a different type of data source with better binding support. Or, you could derive your own class from SortedSet and implement ITypedList.

     

Children
No Data