By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Datagrid sort

P: n/a
Das
Hi,
I'm using c# windows application & set the allowsort property to true. I
wanted to know. when user clicks the header of any column the data is sorted
by that column.

How can I know which is the last sorted field.....

I want to retrieve the currently selected row after the sort....
Thanks in advance...

Regards,

das
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Das,

To get the last sorted field, you would have to handle the click event
for the column header (you can use the HitTest method on the datagrid to
find out if a column is clicked, and which one, I believe). You do this
^before^ you have the default implementation perform the sort.

What you would do in that handler is get the current DataView and find
out what column it is sorted on. Once you have that, you can call the base
implementation, and then get the new column that is being sorted on.

After that, you should be able to get the currently selected row through
the CurrentRowIndex property on the DataGrid itself (you can then use this
to get the row from the dataview that the grid is bound to).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Das" <Da*@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Hi,
I'm using c# windows application & set the allowsort property to true. I
wanted to know. when user clicks the header of any column the data is
sorted
by that column.

How can I know which is the last sorted field.....

I want to retrieve the currently selected row after the sort....
Thanks in advance...

Regards,

das

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.