binding to sub-lists shows wrong columns in VS-designer

Posts   
 
    
JuergenF
User
Posts: 29
Joined: 23-May-2006
# Posted on: 23-May-2006 17:30:20   

Hi, probably already mentioned somewhere, but I couldn't find it, so:

Having the fairly standard Customer 1<->n CustomerContacts, I create self-servicing code.

Then create a form, drag onto it a CustomerCollection and a bindingSource1 bound to that collection.

Now create a DataGridView bound to: DataSource=bindingSource1, DataMember=CustomerContact

This should automatically show all contacts for the current customer (and it does ;-)), but when I edit the DataGridView's columns and add a new column or change the DataPropertyName for a column I get the list for the CustomerEntity, not the CustomerContactEntity 'sublist'. (LLBLGenV1 does show the contact-fields)

If I just create 'dummy'-columns and type the fieldnames manually, then the grid works as expected.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 23-May-2006 18:01:43   

I think this is because the collection is bound to the grid via an EntityView object, which doesn't contain collections as properties. So there are no collections available in the properties of customer. I think (but am not sure and will check it out) this causes the designer of vs.net to think 'oh, there are no collections', but it seems weird as it can find the rest of the columns.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 24-May-2006 16:40:01   

I can't reproduce it, partly due to the annoying bug in teh DataGridView which causes the grid to show just 1 column when I change the datamember of the grid.

Anyway, what I did was: as datasource for the datagrid control, click open the bindingsource1 and you'll see the subcollection there, select that one, and you'll have the columns you need, also in the 'edit columns' form.

Frans Bouma | Lead developer LLBLGen Pro