-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiSelectionHelper.vb
47 lines (38 loc) · 1.46 KB
/
MultiSelectionHelper.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.Utils
Namespace WindowsApplication1
Public Class MultiSelectionHelper
Private _GridView As GridView
Public Sub New(ByVal gridView As GridView)
_GridView = gridView
InitProperties()
SubscribeEvents()
End Sub
Private Sub InitProperties()
_GridView.OptionsBehavior.Editable = False
_GridView.OptionsSelection.MultiSelect = True
_GridView.OptionsSelection.EnableAppearanceFocusedCell = False
_GridView.FocusRectStyle = DrawFocusRectStyle.None
End Sub
Private Sub SubscribeEvents()
AddHandler _GridView.MouseDown, AddressOf _GridView_MouseDown
End Sub
Private Sub _GridView_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
OnMouseDown(e)
End Sub
Private Sub OnMouseDown(ByVal e As MouseEventArgs)
Dim hi As GridHitInfo = _GridView.CalcHitInfo(e.Location)
If Not hi.InRow Then
Return
End If
_GridView.FocusedRowHandle = hi.RowHandle
_GridView.FocusedColumn = hi.Column
_GridView.InvertRowSelection(hi.RowHandle)
DXMouseEventArgs.GetMouseArgs(e).Handled = True
End Sub
End Class
End Namespace