Home All Groups Group Topic Archive Search About

Datagridview and arraylist

Author
13 Oct 2006 5:33 PM
Dwight
You can attach an arraylist to  a datgridview by dgv.datasource =
arraylist.

If the arraylist elements are a class, is there a way to databind this
class to particular columns in grid?

Thanks

Author
13 Oct 2006 5:44 PM
Cor Ligthert [MVP]
Dwight,

How does the program know that all objects in the arraylist are of the same
type.

I never tried it, but I would certainly use a list(of Myclass) in this case.
That is strongly typed so it can only from one type.

Cor

Show quoteHide quote
"Dwight" <dtrumbo***@gmail.com> schreef in bericht
news:1160760818.291450.238490@f16g2000cwb.googlegroups.com...
> You can attach an arraylist to  a datgridview by dgv.datasource =
> arraylist.
>
> If the arraylist elements are a class, is there a way to databind this
> class to particular columns in grid?
>
> Thanks
>
Author
13 Oct 2006 6:33 PM
Dwight
Cor Ligthert [MVP] wrote:
> Dwight,
>
> How does the program know that all objects in the arraylist are of the same
> type.
>
> I never tried it, but I would certainly use a list(of Myclass) in this case.
> That is strongly typed so it can only from one type.
>
> Cor
>

I do use a list(of myclass), but I can't find or understand any
documentation that allows me to bind to columns.

When you do dgv.datasource=arraylist, it just adds new columns with the
data. So basically your class properties are the column names. I want a
little more control than that.