Public Class notCResizegrid
Inherits System.Windows.Forms.DataGrid
Region " Windows 窗体设计器生成的代码 "
Public Sub New ()
MyBase .New()
' 该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
' 在 InitializeComponent() 调用之后添加任何初始化
End Sub
'UserControl 重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose( ByVal disposing As Boolean )
If disposing Then
If Not (components Is Nothing ) Then
components.Dispose()
End If
End If
MyBase .Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
' 注意:以下过程是 Windows 窗体设计器所必需的
' 可以使用 Windows 窗体设计器修改此过程。
' 不要使用代码编辑器修改它。
1<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
2
3components = New System.ComponentModel.Container()
4
5End Sub
6
7# End Region
8
9Protected Overrides Sub OnMouseDown( ByVal e As System.Windows.Forms.MouseEventArgs)
10
11Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
12
13hti = Me .HitTest(e.X, e.Y)
14
15Select Case hti.Type
16
17Case DataGrid.HitTestType.ColumnResize
18
19Return
20
21End Select
22
23MyBase .OnMouseDown(e)
24
25End Sub
26
27Protected Overrides Sub OnMouseMove( ByVal e As System.Windows.Forms.MouseEventArgs)
28
29Dim hti As DataGrid.HitTestInfo = Me .HitTest( New Point(e.X, e.Y))
30
31' 如果鼠标事件类型为改变列宽则返回
32
33If hti.Type = DataGrid.HitTestType.ColumnResize Then
34
35Cursor.Current = Cursors.Default
36
37Return
38
39End If
40
41MyBase .OnMouseMove(e)
42
43End Sub
44
45End Class
46
47’//////////////////////////// 闵峰</system.diagnostics.debuggerstepthrough()>