We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Preventing from Resizing Datagrid Columns

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 Inherits DataGrid 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 End If MyBase.OnMouseMove(e) End Sub End Class

1 Reply

CB Clay Burch Syncfusion Team June 12, 2002 04:10 AM UTC

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 and Me.DataGrid1 = New MyDataGrid()

Live Chat Icon For mobile
Up arrow icon