-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
57 lines (46 loc) · 2.07 KB
/
Form1.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
48
49
50
51
52
53
54
55
56
57
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Views.Grid
Namespace WindowsApplication1
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim tmp_XViewsPrinting = New DevExpress.XtraGrid.Design.XViewsPrinting(gridControl1)
gridView1.OptionsSelection.MultiSelect = True
gridView1.OptionsBehavior.Editable = False
gridView1.OptionsSelection.EnableAppearanceFocusedCell = False
End Sub
Private Sub SelectRows(ByVal view As GridView, ByVal startRow As Integer, ByVal endRow As Integer)
If startRow > -1 AndAlso endRow > -1 Then
view.BeginSelection()
view.ClearSelection()
view.SelectRange(startRow, endRow)
view.EndSelection()
End If
End Sub
Private Function GetRowAt(ByVal view As GridView, ByVal x As Integer, ByVal y As Integer) As Integer
Return view.CalcHitInfo(New Point(x, y)).RowHandle
End Function
Private StartRowHandle As Integer = -1
Private CurrentRowHandle As Integer = -1
Private Sub gridView1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
StartRowHandle = GetRowAt(TryCast(sender, GridView), e.X, e.Y)
End Sub
Private Sub gridView1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim newRowHandle As Integer = GetRowAt(TryCast(sender, GridView), e.X, e.Y)
If CurrentRowHandle <> newRowHandle Then
CurrentRowHandle = newRowHandle
SelectRows(TryCast(sender, GridView), StartRowHandle, CurrentRowHandle)
End If
End Sub
Private Sub gridView1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
StartRowHandle = -1
CurrentRowHandle = -1
End Sub
End Class
End Namespace