Without using a DataTable, how do you go about setting up column information so that the binding code will use it
Basically, I have a data token class that has validation rules in it. So I want to bind to an array of these tokens, instead of using a DataTable (and having to duplicate the validation rules).
So I've created a class that's derived from both ArrayList and IBindingList, which has the code for adding a new row. That's working great, but I'd like to specify my column info in this class as well. Just basic things like the column title, and whether it's read-only.

Setting up Column Binding
Mathieu Descorbeth
Another question - how do you specify the column order I know that GetProperties returns them in the order they're defined, and I expected the columns to get setup in the same order ... but they don't. In fact, no matter what order I define the properties in, they always appear in the same order in the grid - and it's not alphabetical, or by type either. So anyone know what it's basing it on
haus_baus
It's not the binding array class I need to put it in, it's the token class. I've derived it from ICustomTypeDescriptor, overridden the GetProperties methods to return my own class (derived from PropertyDescriptor) which implements it's own DisplayName property. That much works great - the grid columns are now using the display name I specified for the column header.
What I'm still having a problem with is the read-only settings ... I can override the IsReadOnly in my property descriptor class, and in that way lock an entire column. However, what I need is to make the column locked for existing rows only ... for new rows it should still be editable.
I'm trying to pass the token object into my PropertyDescriptor (in the constructor), and then checking an "IsExisting" flag in the IsReadOnly property. But that gives some strange behaviour. At first it looks fine - the column is locked for all existing rows. Go to the 'add new' row and it's editable. But then go to an exiting row again, and back to the 'add new' row, and now it's locked ... add a row, and then go back to the 'add new' row, and now it's editable again ...
Any idea what I'm doing wrong
techstudent26
So I just had to modify my custom Type Descriptor class so that the GetProperties call adjusts the order to match what it gets using Reflection. That way I can control the order of the columns simply by the order in which I define the properties.
Still trying to figure out how to do the read-only properly though, so if anyone has an idea in that regard ...