binding to an empty IBindingListView instance fails

  • Thread starter Thread starter dirk.bonne
  • Start date Start date
D

dirk.bonne

Hi,

I have created my own CustomBindingListView by deriving from
IBindingListView.

Binding a DataGridView to this CustomBindingListView works fine, and
when updates arrive on the underlying data, the DataGridView gets
updated correctly (both changes and additions/removals to the
underlying records set can be seen in the grid).

Except in one case: When I bind to this CustomBindingListView when
there are no items yet in the view.

Then when at a later stage the view gets populated, the grid shows only
empty cells. It seems to recognize that the records are there, and it
shows the rows, except the cells themselves are empty.

When debugging I can see that the rows are requested from the
CustomBindingListView, but that the properties of the items themselves
are never accessed in this case.

I now use a rather painful workaround, that I defer binding until the
binding source get populated, but this is rather a painful business
(register the ListChanged event, watching the CustomBindingListView
instance and check in the handler if the list is non empty. If so, bind
and and unregister the event).

Help! ;-)
Dirk
 
Hi,

Hi,

I have created my own CustomBindingListView by deriving from
IBindingListView.

Binding a DataGridView to this CustomBindingListView works fine, and
when updates arrive on the underlying data, the DataGridView gets
updated correctly (both changes and additions/removals to the
underlying records set can be seen in the grid).

Except in one case: When I bind to this CustomBindingListView when
there are no items yet in the view.

Then when at a later stage the view gets populated, the grid shows only
empty cells. It seems to recognize that the records are there, and it
shows the rows, except the cells themselves are empty.

When debugging I can see that the rows are requested from the
CustomBindingListView, but that the properties of the items themselves
are never accessed in this case.

I now use a rather painful workaround, that I defer binding until the
binding source get populated, but this is rather a painful business
(register the ListChanged event, watching the CustomBindingListView
instance and check in the handler if the list is non empty. If so, bind
and and unregister the event).

A DataView also implements IBindingListView and it doesn't exhibit such
behaviour.

Did you also implement ITypedList *or* did you put a BindingSource between
your custom list and the DataGridView ?

If you did neither, then this might cause the problem because when the list
is empty "DataBinding" can't determine the properties and it thinks there
are no properties.

HTH,
Greetings
 
Hi Bart,

thanks a lot!!!! Thats exactly what I needed to do: implement
ITypedList. I am only a two month old .net baby ;-), so there is a lot
of "know how" I don't know yet about.

saved,
Dirk
 
Back
Top