My Windows datagrid has two columns: one with the data that the user will
see (col_X) and the other one (a hidden one: col_sort) that'll be used to
sort data. When a user clicks on col_X's column header, I'm intercepting the
header click and "telling" it to sort the dataview using col_sort. But for
some reason, the "return" is not being executed. When I press the mouse key,
it'll sort correctly (by col_sort), but as soon as I release the button,
it'll sort by col_x. This is my code:
private void dataGrid_browse_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hitTest;
if (e.Button == MouseButtons.Left)
{
hitTest = dataGrid_browse.HitTest(e.X, e.Y);
if (hitTest.Type == DataGrid.HitTestType.ColumnHeader)
{
DataView dtView = (DataView)dataGrid_browse.DataSource;
if (hitTest.Column == 4) //column 4 is col_X
{
dtView.Sort = "col_sort ASC";
return; //without messageBox or breakpoint , this
instruction is ignored
}
}
}
}
If I put a breakpoint or put a Messagebox inside the "if (hitTest.Column ==
4)" (I force the program to pause), it'll work. But if it does it
continuously, it'll sort by col_sort and then sort by col_x. The "return" is
ignored.
Any help is appreciated.
Thanks.