Search
VB
-
Tips
Visual Basic .Net tips and tricks
1
Previous
Next
DataGrid: Prevent Row And Column Resize
To prevent the user from resizing the rows or columns of a datagrid you need to create a new datagrid. To create a new grid create a class that inherits from datagrid. To prevent the resize prevent the OnMouseDown and OnMouseMove messages from firing when the user is at the resize spot.
Public Class NoResizeGrid
Inherits DataGrid
Protected Overrides Sub OnMouseDown(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 Or hti.Type = DataGrid.HitTestType.RowResize Then
Return 'no baseclass call
End If
MyBase.OnMouseDown(e)
End Sub
Public Sub New()
End Sub
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 Or hti.Type = DataGrid.HitTestType.RowResize Then
Return 'no baseclass call
End If
MyBase.OnMouseMove(e)
End Sub
End Class
1
Previous
Next
Syndication
Rss feed
Select a Category
General Grid Tips
DataGrid Tips
DataGridView Tips
Windows Forms Controls
General Ado.Net Tips
SqlClient Ado.Net Tips
OleDB Ado.Net Tips
Asp.Net Tips
Miscellanous Tips
Vista programming Tips
WPF Tips
Silverlight
Articles
Links
Code Camp
FAQs
VB Related Websites
Microsoft Visual Basic Home Page
Visual Basic .Net Wikipedia Page
Visual Basic Forums
Visual Basic Newsgroup
VB City
Thinq Linq
VB Helper
I love VB