-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiSelectionHelper.cs
55 lines (50 loc) · 1.25 KB
/
MultiSelectionHelper.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.Utils;
namespace WindowsApplication1
{
public class MultiSelectionHelper
{
private GridView _GridView;
public MultiSelectionHelper(GridView gridView)
{
_GridView = gridView;
InitProperties();
SubscribeEvents();
}
private void InitProperties()
{
_GridView.OptionsBehavior.Editable = false;
_GridView.OptionsSelection.MultiSelect = true;
_GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
_GridView.FocusRectStyle = DrawFocusRectStyle.None;
}
private void SubscribeEvents()
{
_GridView.MouseDown += _GridView_MouseDown;
}
private void _GridView_MouseDown(object sender, MouseEventArgs e)
{
OnMouseDown(e);
}
private void OnMouseDown(MouseEventArgs e)
{
GridHitInfo hi = _GridView.CalcHitInfo(e.Location);
if (!hi.InRow)
{
return;
}
_GridView.FocusedRowHandle = hi.RowHandle;
_GridView.FocusedColumn = hi.Column;
_GridView.InvertRowSelection(hi.RowHandle);
DXMouseEventArgs.GetMouseArgs(e).Handled = true;
}
}
}