You have suggested this solution in the Windows Forms FAQ. However, it is not working for me or shall I say that I don't really know how to implement it in my code. I just added a new Class in my project and added the code below. Nothing happens. Should I be calling the class from somewhere?
Public Class MyDataGrid
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X,e.Y))
If hti.Type = DataGrid.HitTestType.ColumnResize Then
Return 'no baseclass call
If you have dropped a datagrid onto your form with the designer, then this datagrid is defined as
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
and created with this code
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
So, the grid being displayed is NOT your MyDataGrid class, but the Systems.Windows.Forms.DataGrid. What you have to do is to make your code use your class. One way to do this is to just change the two statements (even though there are dire warnings about doing so as this code is part of the designer created code).
Friend WithEvents DataGrid1 As MyDataGrid
Me.DataGrid1 = New MyDataGrid()