DataGrid Column sort!

D

DBC User

When you sort a column in a datagrid, it sorts the rows based on the
column and display it properly, but it looses the orignal row which it
was focused before sorting? How can you make it to keep the orignal row
where the focus was, is there an attribute to do this? Or do we have to
do this programmatically?

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

DBC User,

You will have to do this programatically. If you have a consistent
schema for your databases, such that you know how to identify the individual
unique records in the table, you can store the value in that row which
identifies it uniquely before the sort, and then find the row and set the
focus after.

The only other way I can think of doing this for ALL records is to get
the object that the row is bound to, and then cycle the items bound to each
row of the grid, checking for equality.

Hope this helps.
 
D

DBC User

Don't you think it should be a feature in the datagrid itself, since VS
2005 is moving very close to XP theme??
 
N

Nicholas Paldino [.NET/C# MVP]

DBC User,

I don't know what you mean by that, as none of those things matter to
the implementation of the DataGridView.
 

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