|
-
Oct 4th, 2006, 08:38 PM
#1
Thread Starter
Lively Member
How to prevent sorting in datagriview
I have a datagridview named "dgvStudents" and DO NOT want user to click the heading to sort it.
I found the following code but don't know how to incorporate in my code. Can someone please help ?
Public Class CustomDataGrid
Inherits DataGrid
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
Dim point As New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = HitTest(point)
' don't sort column 1
If hti.Type = HitTestType.ColumnHeader AndAlso hti.Column = 1 Then
Return
End If
MyBase.OnMouseDown(e)
End Sub
End Class
-
Oct 4th, 2006, 10:06 PM
#2
Re: How to prevent sorting in datagriview
I think you should be able to just set the SortMode property of each column to NotSortable.
-
Oct 4th, 2006, 10:09 PM
#3
Re: How to prevent sorting in datagriview
Note that the code you posted is NOT for the DataGridView at all:
Public Class CustomDataGrid
Inherits DataGrid
Different beast altogether.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|