Hi,
I'm using a List(of T) as the DataSource for a DataGridView. The list is a
list of objects for which I wrote the class. The headers in the DataGridView
are the names of the properties of the class, and the DataGridView columns
appear in some apparent random order (if not random, I can't figure out what
the order is).

My questions are:
1) how do I control the order of the columns in the DGV (preferably from my
class, or the List(of T) )
2) can I code something in my class to control the DGV headers ( I know I
can use brute force to set the column headers after creating the DGV, but I'd
like to know if I can override the DGV's default behavior by coding something
in my class)

Thanks,
Tom

RE: Binding a DataGridView by PeteMoss

PeteMoss
Thu Aug 02 09:12:04 CDT 2007

Tom,

I'm not 100% sure if this would work, but you could try implementing the
ITypedList interface in your DataSource class. This gives you control over
which properties will be bound to the grid. The DataView class implements
this interface. If you don't implement it directly, the framework uses
reflection to query your public properties as you already know.


RE: Binding a DataGridView by TomCostanza

TomCostanza
Thu Aug 02 10:24:02 CDT 2007

That looks like it might work Pete. Thanks for the tip. I'll post a reply
here if I can make it work.

Best,
Tom

"Pete Moss" wrote:

> Tom,
>
> I'm not 100% sure if this would work, but you could try implementing the
> ITypedList interface in your DataSource class. This gives you control over
> which properties will be bound to the grid. The DataView class implements
> this interface. If you don't implement it directly, the framework uses
> reflection to query your public properties as you already know.
>