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

Adding an object programmatically

I must be missing something here. I have a GridDataBoundGrid class (DocumentGrid) with a class (DocumentList) derived from ArrayList as a data source. DocumentList implements IBindingList. I would now like to programmatically add an existing object (Document)to DocumentList and have it show up in the grid. AddNew does not seem to be the way to go since you can't pass it the Document as a parameter. Any ideas? Thanks! Laurie

2 Replies

AD Administrator Syncfusion Team August 1, 2003 06:02 AM UTC

> I must be missing something here. I have a GridDataBoundGrid class (DocumentGrid) with a class (DocumentList) derived from ArrayList as a data source. DocumentList implements IBindingList. I would now like to programmatically add an existing object (Document)to DocumentList and have it show up in the grid. AddNew does not seem to be the way to go since you can't pass it the Document as a parameter. > > Any ideas? > > Thanks! > Laurie > What does your implementation of IBindingList.AddNew do? Normally, it would create a new object of the proper type and add it to the IBindingList.List, firing the proper notification events along the way. You can see a sample implementation in the \Syncfusion\Essential Suite\Grid\Samples\DataBound\Hierarchical\Customers sample. Once the default new item is in your collection, you could then replace it in your list with your existing object.


AD Administrator Syncfusion Team August 1, 2003 08:16 AM UTC

You could add a new public AddNew method with a different signature, and pass it the existing object so it can be directly added to your list. This new method should make sure the proper ListChanged event is fired. Then you could use this method directly from code to add your existing object.

Loader.
Live Chat Icon For mobile
Up arrow icon