I thought the only thing I had to do to disable column sorting in
VB.NET was to set datagrid.AllowSorting = False. Unfortunately this
has never worked for me. I discovered another set of code that seems
to work for 99% of the cases where I need to disable datagrid column
sorting:
Private Sub datagrid_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles datagrid.MouseDown
Dim pt As New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = dgACE.HitTest(pt)
If hti.Type <> DataGrid.HitTestType.ColumnHeader Then
MyBase.OnMouseDown(e)
End If
End Sub
However, this code does not work when my datagrid resides on a user
control. The datagrid_MouseDown event is triggered but sorting still
occurs for the column. It's critical that I disable sorting in the
datagrid due to the other things I am trying to do with the datagrid.
I'm about ready to pull my hair out trying to figure this one out so
any suggestions on how to resolve this issue would be greatly
appreciated!
Thank you!
Joy