/
Form1.vb
58 lines (50 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
58
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Views.Grid
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim TempXViewsPrinting As DevExpress.XtraGrid.Design.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 System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseDown
StartRowHandle = GetRowAt(TryCast(sender, GridView), e.X, e.Y)
End Sub
Private Sub gridView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseMove
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 System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseUp
StartRowHandle = -1
CurrentRowHandle = -1
End Sub
End Class
End Namespace