Class GridModelSelections
Manages selected ranges in the grid. Allows you to add and remove selections, determine selection state of a specific cell, and more.
Inheritance
Implements
Namespace: Syncfusion.Windows.Controls.Grid
Assembly: Syncfusion.Grid.Wpf.dll
Syntax
public class GridModelSelections : Object, IEnumerable
Constructors
GridModelSelections(GridModel)
Initializes a new GridModelSelections object and associates it with a GridModel.
Declaration
public GridModelSelections(GridModel model)
Parameters
Type | Name | Description |
---|---|---|
GridModel | model | A reference to the parent GridModel. |
Properties
Count
The number of ranges in the GridModelSelections.
Declaration
public int Count { get; }
Property Value
Type |
---|
System.Int32 |
IsSynchronized
Returns False.
Declaration
public bool IsSynchronized { get; }
Property Value
Type |
---|
System.Boolean |
Model
Gets the grid model.
Declaration
public GridModel Model { get; }
Property Value
Type |
---|
GridModel |
Ranges
The collection with all selected ranges.
Declaration
public GridRangeInfoList Ranges { get; }
Property Value
Type |
---|
GridRangeInfoList |
SyncRoot
Returns NULL.
Declaration
public object SyncRoot { get; }
Property Value
Type |
---|
System.Object |
Methods
Add(GridRangeInfo)
Adds a GridRangeInfo to the list of selected ranges.
Declaration
public void Add(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The new selection range to be added. |
ChangeSelection(GridRangeInfo, GridRangeInfo, GridSelectionReason)
Changes an existing selection.
Declaration
public void ChangeSelection(GridRangeInfo oldRange, GridRangeInfo newRange, GridSelectionReason reason)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | oldRange | The range to be changed. |
GridRangeInfo | newRange | The new boundaries of the range. |
GridSelectionReason | reason |
Remarks
The grid calls this method when you select cells with the mouse.
ChangeSelection(GridRangeInfo, GridRangeInfo, Boolean, GridSelectionReason)
Changes an existing selection.
Declaration
public void ChangeSelection(GridRangeInfo oldRange, GridRangeInfo newRange, bool raiseEvents, GridSelectionReason reason)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | oldRange | The range to be changed. |
GridRangeInfo | newRange | The new boundaries of the range. |
System.Boolean | raiseEvents | Specifies if SelectionChanging and SelectionChanged events should be raised. |
GridSelectionReason | reason |
Remarks
The grid calls this method when you select cells with the mouse.
ChangeSelection(GridRangeInfo, GridRangeInfo, Boolean, MouseControllerEventArgs, GridSelectionReason)
Declaration
public void ChangeSelection(GridRangeInfo oldRange, GridRangeInfo newRange, bool raiseEvents, MouseControllerEventArgs e, GridSelectionReason reason)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | oldRange | |
GridRangeInfo | newRange | |
System.Boolean | raiseEvents | |
MouseControllerEventArgs | e | |
GridSelectionReason | reason |
Clear()
Clears all selections.
Declaration
public void Clear()
Clear(Boolean)
Clears all selections.
Declaration
public void Clear(bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseEvents | Indicates if SelectionChanging and SelectionChanged should be raised. |
CopyTo(Array, Int32)
Copies all range objects into an array of GridRangeInfo starting at specified index.
Declaration
public void CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | The array of GridRangeInfo where the values should be copied to. |
System.Int32 | index | The starting index in the destination array. |
GetEnumerator()
Returns an enumerator for stepping through all selected ranges.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | The enumerator for the Ranges collection. |
GetInvertStateRowCol(Int32, Int32, GridRangeInfoList)
Determines if the specified cell position is found in a range list.
Declaration
public bool GetInvertStateRowCol(int rowIndex, int colIndex, GridRangeInfoList rl)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridRangeInfoList | rl | The range list with ranges to be searched. |
Returns
Type | Description |
---|---|
System.Boolean | True if cell position was found; False otherwise. |
GetSelectedCols(Boolean, Boolean)
Returns selected columns in the grid.
Declaration
public GridRangeInfoList GetSelectedCols(bool bRangeColsOnly, bool considerCurrentCell)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bRangeColsOnly | True if only selected columns should be returned; False if you want to treat single range cell selections as full column selections. |
System.Boolean | considerCurrentCell | True if current cell should be returned as selected range if there are no other selected ranges. |
Returns
Type | Description |
---|---|
GridRangeInfoList | The GridRangeInfoList with column ranges. |
Remarks
If the user has selected the cell's range R1C2:R2C4 and the current cell is at R4C5.
If you specify False for bRangeColsOnly
, the method will return range C2:C4.
If you specify True for bRangeColsOnly
and also True for considerCurrentCell
,
the method will return range C5.
GetSelectedRanges(out GridRangeInfoList, Boolean)
Retrieves a list with selected ranges or if there are no selected ranges, returns the current cell as selected range.
Declaration
public bool GetSelectedRanges(out GridRangeInfoList ranges, bool considerCurrentCell)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfoList | ranges | A GridRangeInfoList where selected ranges will be copied to. |
System.Boolean | considerCurrentCell | True if current cell should be returned as selected range if there are no other selected ranges. |
Returns
Type | Description |
---|---|
System.Boolean | True if one or multiple ranges or current cell range could be returned; False otherwise. |
GetSelectedRows(Boolean, Boolean)
Returns selected rows in the grid.
Declaration
public GridRangeInfoList GetSelectedRows(bool bRangeRowsOnly, bool considerCurrentCell)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bRangeRowsOnly | True if only selected rows should be returned; False if you want to treat single range cell selections as full row selections. |
System.Boolean | considerCurrentCell | True if current cell should be returned as selected range if there are no other selected ranges. |
Returns
Type | Description |
---|---|
GridRangeInfoList | The GridRangeInfoList with row ranges. |
Remarks
If the user has selected the cell's range R1C2:R2C4 and the current cell is at R4C5.
If you specify False for bRangeColsOnly
, the method will return range R1:R2.
If you specify True for bRangeColsOnly
and also True for considerCurrentCell
,
the method will return range R4.
InsertColumns(Int32, Int32, GridRangeInfoList)
Inserts the specified no. of columns at the given index.
Declaration
public void InsertColumns(int insertAtColumnIndex, int count, GridRangeInfoList moveState)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | insertAtColumnIndex | The column index to insert. |
System.Int32 | count | No. of columns to insert. |
GridRangeInfoList | moveState | Move state. |
InsertRows(Int32, Int32, GridRangeInfoList)
Inserts the specified no. of rows at the given index.
Declaration
public void InsertRows(int insertAtRowIndex, int count, GridRangeInfoList moveState)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | insertAtRowIndex | The row index to insert. |
System.Int32 | count | No. of rows to insert. |
GridRangeInfoList | moveState | Move state. |
Remove(GridRangeInfo)
Removes a GridRangeInfo from the list of selected ranges.
Declaration
public void Remove(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The new selection range to be added. |
RemoveColumns(Int32, Int32, GridRangeInfoList)
Removes the specified no. of columns from the given index.
Declaration
public void RemoveColumns(int removeAtColumnIndex, int count, GridRangeInfoList moveState)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | removeAtColumnIndex | The column index. |
System.Int32 | count | No. of columns to remove. |
GridRangeInfoList | moveState | Move state. |
RemoveRows(Int32, Int32, GridRangeInfoList)
Removes the specified no. of rows from the given index.
Declaration
public void RemoveRows(int removeAtRowIndex, int count, GridRangeInfoList moveState)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | removeAtRowIndex | The row index. |
System.Int32 | count | No. of rows to remove. |
GridRangeInfoList | moveState | Move state. |
SelectRange(GridRangeInfo, Boolean)
Adds or removes a GridRangeInfo from the list of seletced ranges.
Declaration
public void SelectRange(GridRangeInfo range, bool bSelect)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | The selection range to be added or removed. |
System.Boolean | bSelect | True if range should be added; False otherwise. |