Is there any way to imitate the e.Handled clause for a KeyPress event in a MouseDown event?
Printable View
Is there any way to imitate the e.Handled clause for a KeyPress event in a MouseDown event?
Yes
Exit Sub
would have the same effect as
E.Handled = True
HiTaxes,
Thanks for your reply.
EXIT SUB may well be the way to go, but this is the problem I am having.
I have a datagrid which is sorted on a hidden column called GRADE_HIDDEN.
Now, when a user clicks on the GRADE column header to sort the datagrid, instead of sorting on GRADE, I want it to be sorted on GRADE_HIDDEN.
This is what I have so far in the MouseDown event of my DataGrid.
VB Code:
Dim myGrid As DataGrid = CType(sender, DataGrid) Dim hti As System.Windows.Forms.DataGrid.HitTestInfo Dim view As DataView 'this retrieves the location in the grid that the user clicked using the mouseeventargs for the coordinates hti = myGrid.HitTest(e.X, e.Y) Select Case hti.Type 'evaluate the type of hit test info Case DataGrid.HitTestType.ColumnHeader 'look for the column header If hti.Column = 5 Then 'the column property indicates the index of the column clicked view = New DataView(ds.Tables("INCIDENT"), "", "GRADE_HIDDEN", DataViewRowState.CurrentRows) IncidentList.DataSource = view Exit Sub End If End Select
Now, if I debug this at the Exit Sub line, the grid is indeed sorted on GRADE_HIDDEN.
However, after the Exit Sub, the Sort completes somehow and the grid is re-sorted on the GRADE column.
I suppose what I am asking is "How to re-direct a Datagrid sort to a column other than the one that has been clicked on?"
Hi,
Then there must be something in your subsequent code which affects it.
Put your breakpoint on the Exit Sub and then use the stepover key (F10) to see where it goes. e.g. is there a click or mouseup event in action?
If that fails use DataGrid.Update before the Exit Sub.
Thanks for your Reply.
I've done as you suggest.
However, the code exits after the Exit Sub and doesn't go elsewhere and no other part of my code is called with relation to the DataGrid.
Hi,
I think you need to rebind the control immediately before the Exit Sub
Hi Taxes,
Thought I was doing that already, no?
IncidentList is the name of my DataGrid control.
Hi,
I'll experiment with it later if no one else has an answer.
I'd appreciate any more input you may have Taxes. Many thanks.
Hi,
I think you deed to add the line
IncidentList.DataBind() after
IncidentList.DataSource = view
But I also wonder why you have:
IncidentList instead of MyGrid (Although they are interchangable)