SortCompare of DataGridView - how to?

C

Chris Botha

VS2005 and I have a DataTable displayed in a DataGridView that needs custom
sorting, with the DataSource of the grid set to the DataTable and the
SortCompare event just won't fire.

Then I found this in the docs "This event occurs only when the DataSource
property is not set and the VirtualMode property value is false"
This seems really odd but may be true. I can't see what the purpose of this
event is then, how else will one use the DataGridView other than setting the
DataSource to something?

How else to do the custom sorting when the user clicks a column header is
also welcome.

Thanks.
 
G

Guest

Chris,

It fires when the datagridview is not bound to a datasource and
virtual mode is set to false.

Ken
 
C

Chris Botha

Hi Ken, thanks for the quick response. If you have it working, then I need
more assistance please. I've seen it in the docs, but what the heck does "is
not bound to a datasource" mean?
In my case I have a typed DataSet dataset obtained with a Web service call,
and sets the DataSource of the grid to be the DataTable in the dataset. Does
this cause the event not to fire? As mentioned, this seems really odd. Is
there another way of displaying the table in the grid other than setting the
datasource to the table so the event will fire?
I've tried the VirtualMode property in both its flavors and read all 3 pages
of links coming back with Google searching for DataGridView SortCompare.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top