Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Sorting

Status
Not open for further replies.

Hexcot

Programmer
Nov 9, 2003
20
IN
I have a datagrid having a strongly typed array of objects as its data source.
The data from the array of objects is displayed by means of a table style, which is fine, but I cannot sort the data when I click on the column header.
I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting works on column header click.

What should I do to get the table sorting to wotk with the array of objects?
 
I believe it has something to do with the System.ComponentModel.IBindingList interface. If your DataSource does not support this interface, you will be unable to sort data. You would probably need to create a class that implemented the interface to sort your array:

 
hi,

thanks for your response.

i don't know how to do this. can you please send me the code...

The datagrid sorts when I map it to a data table.
However, when I map the datagrid to an array of objects ( class[] ), I cannot sort on column header click.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top