We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

AddNew - IBindingList

I''m having some problems with my IBindingList again. Sometimes, when I set the grids datasource to my collection, I cannot add new items to the collection, but when I bind it to the same collection but with items in it, it works nicely. Even if I remove every item from my collection, it works, I can still add things. But if my collection is plain new when I datasource the grid to it, then no way I can add new elements: the blank line is there but no call to my collection addNew function is made, I can select data from a combo column (datasourced to some other data), but then, the grid doesn''t add another blank line for a new entry, and whenever I move currentcell, the data entered disapears.

2 Replies

MC Martin Cyr December 2, 2005 09:23 PM UTC

In case my explanation would be confusing or unclear, here is a sample illustrating the behaviour that I described. Just comment the second For loop in the Form1_Load to see the problem. P.S. We''re using SF Essential Studio 3.301.0.0

IBindingListDemo.zip


AD Administrator Syncfusion Team December 3, 2005 11:39 AM UTC

Thanks for the sample. When your list is empty, then grid needs to be able to get at the type of the objects in the list in order to initialize the associated property descriptors properly. In your collection, you added an attribute to indicate the type of the object in the collection. But Essential Grid does not look for this type of attribute. Instead, it relies on the collection implementing ITypedList to enable it to handle empty lists as datasources. So, I was able to get you sample working by adding Implements System.ComponentModel.ITypedList and
    Public Function GetItemProperties(ByVal listAccessors() As System.ComponentModel.PropertyDescriptor) As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ITypedList.GetItemProperties
        Return System.ComponentModel.TypeDescriptor.GetProperties(GetType(Blah))
    End Function

    Public Function GetListName(ByVal listAccessors() As System.ComponentModel.PropertyDescriptor) As String Implements System.ComponentModel.ITypedList.GetListName
        Return "Blah"
    End Function
to your collection class.

Loader.
Live Chat Icon For mobile
Up arrow icon