1
- Imports Microsoft.VisualBasic
2
1
Imports System
3
- Imports System.Collections.Generic
4
2
Imports System.ComponentModel
5
- Imports System.Data
6
3
Imports System.Drawing
7
- Imports System.Text
8
4
Imports System.Windows.Forms
9
5
Imports DevExpress.XtraGrid.Views.Grid
10
6
11
7
Namespace WindowsApplication1
12
- Partial Public Class Form1
13
- Inherits Form
14
- Public Sub New ()
15
- InitializeComponent()
16
- End Sub
17
-
18
- Private Sub Form1_Load( ByVal sender As Object , ByVal e As EventArgs) Handles MyBase .Load
19
- Dim TempXViewsPrinting As DevExpress.XtraGrid.Design.XViewsPrinting = New DevExpress.XtraGrid.Design.XViewsPrinting(gridControl1)
20
- gridView1.OptionsSelection.MultiSelect = True
21
- gridView1.OptionsBehavior.Editable = False
22
- gridView1.OptionsSelection.EnableAppearanceFocusedCell = False
23
- End Sub
24
-
25
- Private Sub SelectRows( ByVal view As GridView, ByVal startRow As Integer , ByVal endRow As Integer )
26
- If startRow > - 1 AndAlso endRow > - 1 Then
27
- view.BeginSelection()
28
- view.ClearSelection()
29
- view.SelectRange(startRow, endRow)
30
- view.EndSelection()
31
- End If
32
- End Sub
33
-
34
- Private Function GetRowAt( ByVal view As GridView, ByVal x As Integer , ByVal y As Integer ) As Integer
35
- Return view.CalcHitInfo( New Point(x, y)).RowHandle
36
- End Function
37
-
38
- Private StartRowHandle As Integer = - 1
39
- Private CurrentRowHandle As Integer = - 1
40
-
41
- Private Sub gridView1_MouseDown( ByVal sender As Object , ByVal e As System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseDown
42
- StartRowHandle = GetRowAt( TryCast (sender, GridView), e.X, e.Y)
43
- End Sub
44
-
45
- Private Sub gridView1_MouseMove( ByVal sender As Object , ByVal e As System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseMove
46
- Dim newRowHandle As Integer = GetRowAt( TryCast (sender, GridView), e.X, e.Y)
47
- If CurrentRowHandle <> newRowHandle Then
48
- CurrentRowHandle = newRowHandle
49
- SelectRows( TryCast (sender, GridView), StartRowHandle, CurrentRowHandle)
50
- End If
51
- End Sub
52
-
53
- Private Sub gridView1_MouseUp( ByVal sender As Object , ByVal e As System.Windows.Forms.MouseEventArgs) Handles gridView1.MouseUp
54
- StartRowHandle = - 1
55
- CurrentRowHandle = - 1
56
- End Sub
57
- End Class
58
- End Namespace
8
+
9
+ Public Partial Class Form1
10
+ Inherits Form
11
+
12
+ Public Sub New ()
13
+ InitializeComponent()
14
+ End Sub
15
+
16
+ Private Sub Form1_Load( ByVal sender As Object , ByVal e As EventArgs)
17
+ Dim tmp_XViewsPrinting = New DevExpress.XtraGrid.Design.XViewsPrinting(gridControl1)
18
+ gridView1.OptionsSelection.MultiSelect = True
19
+ gridView1.OptionsBehavior.Editable = False
20
+ gridView1.OptionsSelection.EnableAppearanceFocusedCell = False
21
+ End Sub
22
+
23
+ Private Sub SelectRows( ByVal view As GridView, ByVal startRow As Integer , ByVal endRow As Integer )
24
+ If startRow > - 1 AndAlso endRow > - 1 Then
25
+ view.BeginSelection()
26
+ view.ClearSelection()
27
+ view.SelectRange(startRow, endRow)
28
+ view.EndSelection()
29
+ End If
30
+ End Sub
31
+
32
+ Private Function GetRowAt( ByVal view As GridView, ByVal x As Integer , ByVal y As Integer ) As Integer
33
+ Return view.CalcHitInfo( New Point(x, y)).RowHandle
34
+ End Function
35
+
36
+ Private StartRowHandle As Integer = - 1
37
+
38
+ Private CurrentRowHandle As Integer = - 1
39
+
40
+ Private Sub gridView1_MouseDown( ByVal sender As Object , ByVal e As MouseEventArgs)
41
+ StartRowHandle = GetRowAt( TryCast (sender, GridView), e.X, e.Y)
42
+ End Sub
43
+
44
+ Private Sub gridView1_MouseMove( ByVal sender As Object , ByVal e As MouseEventArgs)
45
+ Dim newRowHandle As Integer = GetRowAt( TryCast (sender, GridView), e.X, e.Y)
46
+ If CurrentRowHandle <> newRowHandle Then
47
+ CurrentRowHandle = newRowHandle
48
+ SelectRows( TryCast (sender, GridView), StartRowHandle, CurrentRowHandle)
49
+ End If
50
+ End Sub
51
+
52
+ Private Sub gridView1_MouseUp( ByVal sender As Object , ByVal e As MouseEventArgs)
53
+ StartRowHandle = - 1
54
+ CurrentRowHandle = - 1
55
+ End Sub
56
+ End Class
57
+ End Namespace
0 commit comments