Skip to content

Commit 8500793

Browse files
ES-976509 - Resolved the ReadMe file changes in the sample repository
1 parent 0b87b7a commit 8500793

File tree

5 files changed

+133
-2
lines changed

5 files changed

+133
-2
lines changed
27.8 KB
Loading
32.3 KB
Loading
34.5 KB
Loading
26.2 KB
Loading

README.md

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,133 @@
1-
# WPF-GridControl-Selection
2-
This repository contains the samples which shows the different selection of WPF GridControl.
1+
# WPF GridControl Selection
2+
3+
This repository contains the samples which shows the different selection of [WPF GridControl](https://www.syncfusion.com/wpf-controls/excel-like-grid).
4+
5+
## Selection modes
6+
There are two modes of selection available in the GridControl. They are,
7+
8+
* Range selection
9+
* Record selection
10+
11+
### Range selection
12+
1. In Range selection, you will be able to select cell ranges; but the selections will have no knowledge of nested tables, grouping or sorting and hence the functionality is limited like a data bound grid (GridData control).
13+
2. To use the model selection capability, set AllowSelections to any flag except none.
14+
3. Selection can be made through keyboard and mouse.
15+
16+
### Record selection
17+
1. It is designed specifically for the data bound grids.
18+
2. In Record selection, the complete grid records (rows) will be selected and these selections function properly with nested tables, sorting, and so on.
19+
3. To use the record selections, you must set AllowSelections to none and then set ListBoxSelectionMode to any flag except none.
20+
4. Selection can be made through keyboard and mouse with some restriction. For more details, see Record-based Selection in this topic.
21+
22+
## Range selection
23+
Range selection is a cell-based selection mode that allows you to do a selection across the cell by using the [AllowSelection](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridModelOptions.html#Syncfusion_Windows_Controls_Grid_GridModelOptions_AllowSelection) property. It accepts value from [GridSelectionFlags](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridSelectionFlags.html) enumeration. Default value for `AllowSelection` is `Any` and the specified range of Cell/Row/Column or Table can be highlighted using the range section.
24+
25+
The possible values for this type of selection are defined by the enum `GridSelectionFlags`. To control the selection behavior of the grid, set any of the following flags to the AllowSelection property.
26+
27+
### Selection flags
28+
29+
<table>
30+
<tr>
31+
<th>
32+
Flag</th><th>
33+
Description</th></tr>
34+
<tr>
35+
<td>
36+
None</td><td>
37+
Disables selecting of cells.</td></tr>
38+
<tr>
39+
<td>
40+
Row</td><td>
41+
Allows selection of rows.</td></tr>
42+
<tr>
43+
<td>
44+
Column</td><td>
45+
Allows selection of columns.</td></tr>
46+
<tr>
47+
<td>
48+
Table</td><td>
49+
Allows selection of the whole table.</td></tr>
50+
<tr>
51+
<td>
52+
Cell</td><td>
53+
Allows selection of an individual cell.</td></tr>
54+
<tr>
55+
<td>
56+
Multiple</td><td>
57+
Allows selection of multiple ranges of cells. The user has to press CTRL Key to select multiple ranges.</td></tr>
58+
<tr>
59+
<td>
60+
Shift</td><td>
61+
Allows extending existing selection when user holds SHIFT Key and clicks on a cell.</td></tr>
62+
<tr>
63+
<td>
64+
Keyboard</td><td>
65+
Allows extending existing selection when user holds SHIFT Key and presses arrow keys.</td></tr>
66+
<tr>
67+
<td>
68+
MixRangeType</td><td>
69+
Allows both rows and columns to be selected at the same time when Multiple is specified. By default, the grid does not allow row and column ranges to be selected at the same time.</td></tr>
70+
<tr>
71+
<td>
72+
Any</td><td>
73+
Allows selection of rows, columns, table, cell and multiple ranges of cells; also extends SHIFT Key support and alpha blending.</td></tr>
74+
</table>
75+
76+
**Note:** You can combine more than one flag to customize the current selection behavior.
77+
78+
``` csharp
79+
grid.Model.Options.AllowSelection = GridSelectionFlags.Multiple | GridSelectionFlags.Column;
80+
```
81+
82+
![GridControl with multiple columns selected](GridControlWithMultipleSelectionMode.png)
83+
84+
## Record selection
85+
This type of selection mechanism allows selection in terms of record (entire row). It is not cell-based. This selection mode is specifically designed for a data-bound grid, in which the grid data can be organized as a collection of record rows.
86+
87+
Grid offers the following three types of record selections which are together called as [ListBoxSelectionMode](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridModelOptions.html#Syncfusion_Windows_Controls_Grid_GridModelOptions_ListBoxSelectionMode).
88+
89+
* SelectionMode - One
90+
* SelectionMode - MultiSimple
91+
* SelectionMode - MultiExtended
92+
93+
To enable record selection, set the `ListBoxSelectionMode` property to any of the above specified List Box Selection Mode values. To enable list box selection, turn off the range selection by setting the `AllowSelection` property to `Row`. Below is a detailed description of list box selection modes.
94+
95+
### SelectionMode-One
96+
It allows you to select only one item (record). For example, you have selected a record. Now if you select some other record, the previous record selection will be cleared. Hence it is a One record selection mode.
97+
98+
``` csharp
99+
grid.AllowSelection = GridSelectionFlags.Row;
100+
grid.Model.Options.ListBoxSelectionMode = GridSelectionMode.One;
101+
```
102+
103+
![GridControl with single row selected](GridControlWithOneSelectionMode.png)
104+
105+
**Note:** Record can be selected using a single mouse click or using UP or DOWN Arrow Keys
106+
107+
### SelectionMode - MultiSimple
108+
In this selection mode, you will be able to select multiple items individually. For instance, you have selected a record using mouse and you want to select one more record. Click another record and you will notice that the previous selection is not cleared. Hence You can select multiple records without the need of SHIFT or CTRL keys.
109+
110+
``` csharp
111+
grid.AllowSelection = GridSelectionFlags.Row;
112+
grid.Model.Options.ListBoxSelectionMode = GridSelectionMode.MultiSimple;
113+
```
114+
115+
![GridControl with Multiple row selected](GridControlWithMultipleRowSelectionMode.png)
116+
117+
**Note:** It does not support the use of SHIFT, CTRL and arrow keys to extend the selection.
118+
119+
### SelectionMode - MultiExtended
120+
This selection type allows multiple items selection through SHIFT, CTRL and arrow keys.
121+
122+
You can do any of the following when this selection mode is enabled:
123+
124+
* Select a record, hold down the SHIFT key and select fourth record, for example. You will notice all the records in between 1st and the 4th records are also selected.
125+
* You can make random selection by holding down the CTRL key.
126+
* Hold down the Shift key and select the records using the UP or DOWN ARROW keys.
127+
128+
``` csharp
129+
grid.AllowSelection = GridSelectionFlags.Row;
130+
grid.Model.Options.ListBoxSelectionMode = GridSelectionMode.MultiExtended;
131+
```
132+
133+
![GridControl with multiple rows selected with extended selection mode](GridControlWithExtendedRowSelectionMode.png)

0 commit comments

Comments
 (0)