470,596 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Custom Data Binding to Grid and TableStyles

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
2 1857
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.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"sandman" <an*******@devdex.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 15 '05 #2
KW
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.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.