|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
binding to an empty IBindingListView instance failsI 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,
<dirk.bo***@gmail.com> wrote in message Show quoteHide quote news:1139308810.518995.203540@o13g2000cwo.googlegroups.com... A DataView also implements IBindingListView and it doesn't exhibit such > 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). > 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 Show quoteHide quote > Help! ;-) > Dirk >
Other interesting topics
|
|||||||||||||||||||||||