Binding llbl versus generic list collection

Posts   
 
    
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 02-May-2006 00:45:15   

When I go: Datagridview.datasource = llblcollection, properties come up in grid in order of fields in tables, and with some intelligent widths already there, (I believe);

If I do the same binding with my own custom generic List collection the order of the columns in the datagridview (winforms) is some order I can't even guess at. Not alpabetical, not datatype, length, etc.

Is there any simple thing that can be done besides working with rows and columns to get your kind of binding functionality?

Thanks,

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-May-2006 07:04:43   

Is there any simple thing that can be done besides working with rows and columns to get your kind of binding functionality?

I don't know what you mean by working with rows and columns. But did you use the Edit Columns dialog to define column names with the order you want?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 02-May-2006 08:42:39   

Add the data to the .NET 2.0's BindingList<T>. It should get better results. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 02-May-2006 18:46:16   

What I want to do is use a custom collection to bind to datagridview with datasource = collection.

Working with rows and columns: means: creating a row object, creating cells off the edit columns data, then filling cells with data to bind.

Sounds like I just have to find bindinglist<T> versus List<T>.

Thanks,

tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 02-May-2006 18:57:58   

Just for fyi: BindingList<T> had no visible advantage over List<T>.

Fields came up in wierd order with no widths related to data width etc. That's wierd that they would put BindingList in ComponentModel namespace, and List<T> in system.collections.generic!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 03-May-2006 10:56:27   

It's the order in which properties are gathered from the type. So they can be in any order. The philosophy is, that in design time databinding you select / order the columns and be done with it. Because... what's the RIGHT order of the columns ? simple_smile The order in which they're specified in the entity?

If you want to get this solved with a property sort routine, you can look at implementing ITypedList yourself. Check my article on that here: http://weblogs.asp.net/fbouma/articles/115837.aspx

Frans Bouma | Lead developer LLBLGen Pro