Overriding the DataGrid (prevents column widths from being dragged)

Source: Internet
Author: User
Tags modify
Datagrid

Public Class Notcresizegrid

Inherits System.Windows.Forms.DataGrid

#Region "code generated by the Windows forms Designer"

Public Sub New ()

MyBase.New ()

' This call is required by the Windows Forms Designer.

InitializeComponent ()

' Add any initialization after the InitializeComponent () call

End Sub

' UserControl overrides dispose to clean up the list of components.

Protected Overloads Overrides Sub Dispose (ByVal disposing as Boolean)

If disposing Then

If not (components are nothing) Then

Components. Dispose ()

End If

End If

Mybase.dispose (disposing)

End Sub

' Required by the Windows Forms Designer

Private Components as System.ComponentModel.IContainer

' NOTE: The following procedure is required by the Windows Forms Designer

' You can use the Windows Forms Designer to modify this procedure.

' Do not modify it using the Code Editor.

<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()

components = New System.ComponentModel.Container ()

End Sub

#End Region

Protected Overrides Sub OnMouseDown (ByVal e as System.Windows.Forms.MouseEventArgs)

Dim Hti as System.Windows.Forms.DataGrid.HitTestInfo

Hti = Me.hittest (e.x, e.y)

Select case Hti. Type

Case DataGrid.HitTestType.ColumnResize

Return

End Select

Mybase.onmousedown (e)

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 the mouse event type is changing the column width, return

If Hti. Type = DataGrid.HitTestType.ColumnResize Then

Cursor.current = Cursors.Default

Return

End If

Mybase.onmousemove (e)

End Sub End Class



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.