IBindingList and DataGrid

P

Phillip

I have a DataGrid bound to a custom collection that
implements IBindingList. The collection returns true for
AllowNew. The collections AddNew() method creates a new
object, adds it to the collection and returns the new
object.

The SupportsChangeNotification property returns true and
the appropriate ListChangedEventArgs are used in the
ListChanged event. All fine no problem. However:

If there are items in the collection, and therefore items
in the DataGrid, when the AddNew() method of the
collection is called, all is well and the datagrid adds a
new blank row bound to the new object. Super.

If however the collection is empty, and therefore no rows
in the DataGrid, when AddNew() method of the collection is
called, the DataGrid responds by adding a new row, but
with no columns. Just a tiny bit of white on the left hand
side of the area where the columns are supposed to be.

I have tried calling Invalidate and refresh on the Grid
but this has not helped.

Any help would me most appreciated.

Many thanks

Phillip.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Phillip,

I know that, for DataTables, a detached row is created when the user goes to
the "Add New" row in the grid. This row then turns to an added one when the
user goes off the "Add New" row. So, you could probably try to mimic this
behavior?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top