Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class datagridviewRidimensionabile
- Inherits DataGridView
- Private layerFondoFinestra As Region
- Private layerLatoFinestra As Region
- Private origine As Point
- Private selezioneLaterale As Boolean
- Private selezioneFondo As Boolean
- Private Sub CreaLayer()
- layerFondoFinestra = New Region(New Rectangle(0, Me.Height - 5, Me.Width, 5))
- layerLatoFinestra = New Region(New Rectangle(Me.Width - 5, 0, 5, Me.Height))
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = MouseButtons.Left Then
- If layerFondoFinestra.IsVisible(e.Location) Then
- origine = e.Location
- selezioneFondo = True
- End If
- If layerLatoFinestra.IsVisible(e.Location) Then
- origine = e.Location
- selezioneLaterale = True
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- selezioneFondo = False
- selezioneLaterale = False
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- Dim differenza As Point = origine - e.Location
- If selezioneLaterale = True Then
- Me.Width -= differenza.X
- End If
- If selezioneFondo = True Then
- Me.Height -= differenza.Y
- End If
- If layerFondoFinestra.IsVisible(e.Location) Or layerLatoFinestra.IsVisible(e.Location) Then
- Cursor = Cursors.Hand
- Else
- Cursor = Cursors.Default
- End If
- origine = e.Location
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- creaLayer()
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- creaLayer()
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- CreaLayer()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement