Bind an entitycollection to a DataGridView

Posts   
 
    
kal
User
Posts: 18
Joined: 25-May-2010
# Posted on: 25-May-2010 15:06:09   

Hi folks,

i'm using LLBLGEn Pro 2.0, and i'm build a WinForm .NET 2.0 application.

I have a DataGridView bound to a Collection, like that :


            vjfCollectionAvecCogeneration = new VJFCollection();
            PredicateExpression filtre = new PredicateExpression(VJFFields.IsCogeneration == true);
            vjfCollectionAvecCogeneration.GetMulti(filtre);

            gridAvecCogeneration.DataSource = vjfCollectionAvecCogeneration;

The point is that my column names are the property names of my collection. I would like to define custom column names. Do I have to that this way :


            gridAvecCogeneration.Columns[0].Name = "PDC avec cogénération";

Or is there a proper way like using an EntityView?

Thanks, Kal

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 25-May-2010 22:57:31   

You have to use the .HeaderText property - see

http://stackoverflow.com/questions/125719/datagridview-edit-column-names

for details (and lot of other general coding related goodness...simple_smile )

Matt

kal
User
Posts: 18
Joined: 25-May-2010
# Posted on: 31-May-2010 18:39:06   

MTrinder wrote:

You have to use the .HeaderText property - see

http://stackoverflow.com/questions/125719/datagridview-edit-column-names

for details (and lot of other general coding related goodness...simple_smile )

Matt

Thanks a lot, it made the trick!