WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridModelSelections

    Show / Hide Table of Contents

    Class GridModelSelections

    implements the methods that manages selected ranges in the grid. Allows you to add and remove selections, determine selection state of a specific cell, and more.

    Inheritance
    System.Object
    NonFinalizeDisposable
    GridModelBound
    GridModelSelections
    Implements
    System.IDisposable
    System.Collections.IEnumerable
    Inherited Members
    GridModelBound.Dispose(Boolean)
    GridModelBound.OnModelDeserialization(Object, GridModel)
    GridModelBound.SetModelInt(GridModel)
    GridModelBound.Model
    NonFinalizeDisposable.Dispose()
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.Windows.Forms.Grid
    Assembly: Syncfusion.Grid.Windows.dll
    Syntax
    public class GridModelSelections : GridModelBound, IDisposable, IEnumerable

    Constructors

    GridModelSelections(GridModel)

    Initializes a new instance of GridModelSelections class 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

    Gets the number of ranges in the GridModelSelections.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    IsSynchronized

    Gets a value indicating whether Is Synchronized. Returns False.

    Declaration
    public bool IsSynchronized { get; }
    Property Value
    Type Description
    System.Boolean

    Ranges

    Gets the collection with all selected ranges.

    Declaration
    public GridRangeInfoList Ranges { get; }
    Property Value
    Type Description
    GridRangeInfoList

    SyncRoot

    Gets NULL.

    Declaration
    public object SyncRoot { get; }
    Property Value
    Type Description
    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)

    Changes an existing selection.

    Declaration
    public void ChangeSelection(GridRangeInfo oldRange, GridRangeInfo newRange)
    Parameters
    Type Name Description
    GridRangeInfo oldRange

    The range to be changed.

    GridRangeInfo newRange

    The new boundaries of the range.

    Remarks

    The grid calls this method when you select cells with the mouse.

    ChangeSelection(GridRangeInfo, GridRangeInfo, Boolean)

    Changes an existing selection.

    Declaration
    public void ChangeSelection(GridRangeInfo oldRange, GridRangeInfo newRange, bool raiseEvents)
    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.

    Remarks

    The grid calls this method when you select cells with the mouse.

    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:C5.

    If you specify True for bRangeColsOnly and also True for considerCurrentCell,
    the method will return range C5.

    GetSelectedRanges(out GridRangeInfoList, Boolean)

    Determines 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;R4.

    If you specify True for bRangeColsOnly and also True for considerCurrentCell, the method will return range R4.

    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.

    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.

    SetSelectClickRowCol(Int32, Int32)

    Sets internal properties to simulate having clicked a particular row and col to start a shift-selection process.

    Declaration
    public void SetSelectClickRowCol(int rowIndex, int colIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The grid row index.

    System.Int32 colIndex

    The grid column index.

    Remarks

    When you explicitly call gridControl1.Selections.SelectRange to select cells, the grid does not treat this the same as clicking on the cells to select them. When you click cells to select them, internal fields track the clicks so that the selection can be extended using additional shift+clicks. If you want your range selected by using gridControl1.Selections.SelectRange to be extendible in this manner, then you will need to make an additional call to tell the grid to set its internal fields.

    Examples

    The code shows a simple use case.

    gridControl1.Selections.SelectRange(GridRangeInfo.Row(1), true);
    gridControl1.Selections.SetSelectClickRowCol(1, 0);

    SetSelectClickRowCol(Int32, Int32, GridSelectCellsMouseController)

    Sets internal properties to simulate having clicked a particular row and col to start a shift-selection process.

    Declaration
    public void SetSelectClickRowCol(int rowIndex, int colIndex, GridSelectCellsMouseController mc)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The grid row index.

    System.Int32 colIndex

    The grid column index.

    GridSelectCellsMouseController mc

    The GridSelectCellsMouseController mouse controller.

    Remarks

    When you explicitly call gridControl1.Selections.SelectRange to select cells, the grid does not treat this the same as clicking on the cells to select them. When you click cells to select them, internal fields track the clicks so that the selection can be extended using additional shift+clicks. If you want your range selected by using gridControl1.Selections.SelectRange to be extendible in this manner, then you will need to make an additional call to tell the grid to set its internal fields.

    Implements

    System.IDisposable
    System.Collections.IEnumerable

    Extension Methods

    EnumerableExtensions.GetElementType(IEnumerable)
    EnumerableExtensions.GetItemPropertyInfo(IEnumerable)
    FunctionalExtensions.ForEach<T>(IEnumerable, Action<T>)
    FunctionalExtensions.ToList<T>(IEnumerable)
    QueryableExtensions.OfQueryable(IEnumerable)
    QueryableExtensions.OfQueryable(IEnumerable, Type)
    QueryableExtensions.GroupByMany<TElement>(IEnumerable, Type, List<Func<TElement, Object>>)
    QueryableExtensions.GroupByMany(IEnumerable, Type, Func<String, Expression>, String[])
    QueryableExtensions.GroupByMany(IEnumerable, Type, List<SortDescriptor>, Dictionary<String, IComparer<Object>>, Func<String, Expression>, String[])
    QueryableExtensions.GroupByMany(IEnumerable, Type, List<SortDescriptor>, Func<String, Expression>, String[])
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved