Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.ComponentModel.BindingList: Add(object) vs. AddNew()

What is the difference between the System.ComponentModel.BindingList methods Add(object) and AddNew()? The MSDN documentation says this:

  • Add: Adds an object to the end of the Collection<T>.

  • AddNew: Adds a new item to the collection.

It seems like both methods add an item to the collection, but Add(object) does it in one shot whereas AddNew() is slightly more complicated. My tests with Add(object) seem to be working, but I want to know if I am using the correct method.

So what is the difference between these methods?

like image 224
user1214135 Avatar asked Apr 17 '12 19:04

user1214135


1 Answers

AddNew() creates the object for you (that's why it doesn't have a parameter).
It's designed to be used by grids, which don't know how to create a new object to pass to Add().

like image 108
SLaks Avatar answered Sep 19 '22 03:09

SLaks