Custom Data Binding to Grid and TableStyles

  • Thread starter Thread starter sandman
  • Start date Start date
S

sandman

I've got some custom classes that implement IBindingList so I can bind
them to a DataGrid. My test app works fine. So then I tried to format
the columns - I have a function that creates a TableStyles object,
formats all the columns, set the headers, column width, column order,
etc. I tried calling it in the form constructor after
InitializeComponent, I tried calling it in the Form_Load() event
handler. I tried calling it before I bound the custom class to the data
grid. But the grid just ignores my settings. I can't even figure out how
it's deciding what order to display the columns. Does anybody know
where/how I can override whatever the grid is doing by default?

margaret
 
Hi,

Esnure you bind the grid AFTER (with the SetDataBinding method!) you have
initalized it with the TableStyles. As far as I remember, it doesn't work
the other way around.
 
You also need to set the MappingName of the TableStyle to the name of
your Custom Class. So, if your custom collection class is called
'MyCollectionClass', set the mapping name to that. The same thing
applies if you were using dataviews or datasets to bind to a grid, but
you would instead use the name of the table in the dataview, or dataset.
Hope this helps.
 
Back
Top