E
ECD
Hello all,
I can usually find solutions to my .NET problems by searching these
groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0
framework). I want to disable sorting on the first column in the grid
only. I havent found a way to reliably do this yet.
I tried putting the following code in the datagrid's mouse down event
Dim hti As DataGrid.HitTestInfo
hti =
dgCompList.HitTest(dgCompList.PointToClient(Control.MousePosition))
If hti.Type = DataGrid.HitTestType.ColumnHeader Then
If hti.Column = 0 Then
dgCompList.TableStyles(0).AllowSorting = False
dgCompList.AllowSorting = False
Else
dgCompList.TableStyles(0).AllowSorting = True
dgCompList.AllowSorting = True
End If
End If
This almost works, except the first time I click on the column heading
for row zero, the sort happens, but further clicks behave as expected
(no sorting). Its almost as though the sort event fires before I am
able to disable the sorting on the grid. Any ideas? Thanks in
advance.
Eric
I can usually find solutions to my .NET problems by searching these
groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0
framework). I want to disable sorting on the first column in the grid
only. I havent found a way to reliably do this yet.
I tried putting the following code in the datagrid's mouse down event
Dim hti As DataGrid.HitTestInfo
hti =
dgCompList.HitTest(dgCompList.PointToClient(Control.MousePosition))
If hti.Type = DataGrid.HitTestType.ColumnHeader Then
If hti.Column = 0 Then
dgCompList.TableStyles(0).AllowSorting = False
dgCompList.AllowSorting = False
Else
dgCompList.TableStyles(0).AllowSorting = True
dgCompList.AllowSorting = True
End If
End If
This almost works, except the first time I click on the column heading
for row zero, the sort happens, but further clicks behave as expected
(no sorting). Its almost as though the sort event fires before I am
able to disable the sorting on the grid. Any ideas? Thanks in
advance.
Eric