How to select 1st row after changing column SortOrder?

J

Jeroen

Hi,



In a DataGrid using a DataView it's possible to change the column sortorder
simply by clicking the column in the row header.

Just after that, I would like to select the 1st entire row in the DataGrid
using DataGrid.Select(0).



I tried catching MouseDown, MouseUp, DataView.ListChanged events. I know
then that the sortorder has changed. Selecting the 1st row there does not
seem to have a possitive result. It seems that after my code, the
DataGrid/DataView does something I cannot get at.

I also derived from DataGrid and used the protected event RowHeaderClick.
When debugging, it never comes there! Strange.



Has anyone any ideas/tips?

Thanks in advance.



Best regards,



Jeroen
 
B

Bialy

hello,

It can be done by overriding the grids OnMouseUp method like this:

protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
base.OnMouseUp(e);
DataGrid.HitTestInfo hti = this.HitTest(e.X, e.Y);
if (hti.Type == DataGrid.HitTestType.ColumnHeader)
{
this.Select(0);
}
}

Hope it helps,

bialy
 

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