menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridData - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class GridData

    Implement this class to hold StyleInfoStore objects with cell specific style properties. Rows and columns are allocated on demand and only for cells that have actual contents will a StyleInfoStore object be allocated.

    Inheritance
    System.Object
    GridData
    Implements
    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.Runtime.Serialization.IDeserializationCallback
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Syncfusion.Windows.Forms.Grid
    Assembly: Syncfusion.Grid.Windows.dll
    Syntax
    public class GridData : ICloneable, ISerializable, IDeserializationCallback
    Remarks

    GridData also holds information about row, column, and table styles and row and column headers.

    Constructors

    GridData()

    Initializes a new instance of the GridData class.

    Declaration
    public GridData()

    GridData(SerializationInfo, StreamingContext)

    Initializes a new instance of GridData from a serialization stream.

    Declaration
    public GridData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info

    An object that holds all the data needed to serialize or de-serialize this instance.

    System.Runtime.Serialization.StreamingContext context

    Describes the source and destination of the serialized stream specified by info.

    Properties

    ColCount

    Gets or sets the column count in the GridData table.

    Declaration
    public virtual int ColCount { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    The column count does not include headers and row styles. If you set the column count to be 2, there will be one row header, one row style, and two grid columns with cells.

    ColStyles

    Gets access to column styles data.

    Declaration
    public GridDataColStylesIndexer ColStyles { get; }
    Property Value
    Type
    GridDataColStylesIndexer

    ExtendedInfo

    Gets or sets a custom object or tag to be saved with the GridData object.

    Declaration
    public object ExtendedInfo { get; set; }
    Property Value
    Type
    System.Object
    Remarks

    Clipboard copy / paste will for example store covered ranges information in ExtendedInfo.

    Item[Int32, Int32]

    Gets or sets the cell contents at the specified row and column index.

    Declaration
    public GridStyleInfoStore this[int rowIndex, int colIndex] { get; set; }
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The row index. Can be 0 for column headers and -1 for column styles.

    System.Int32 colIndex

    The column index. Can be 0 for row headers and -1 for row styles.

    Property Value
    Type Description
    GridStyleInfoStore

    A GridStyleInfoStore with the specified cell's data. Can be NULL if cell has not been initialized for the specified position.

    Modified

    Gets a value indicating whether the dictionary was modified.

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

    RowCount

    Gets or sets the row count in the GridData table.

    Declaration
    public virtual int RowCount { get; set; }
    Property Value
    Type
    System.Int32
    Remarks

    The row count does not include headers and column styles. If you set the row count to be 2, there will be one column header, one column style, and two grid rows with cells.

    Rows

    Gets access to row styles data.

    Declaration
    public GridRowCollection Rows { get; }
    Property Value
    Type
    GridRowCollection

    RowStyles

    Gets access to row styles data.

    Declaration
    public GridDataRowStylesIndexer RowStyles { get; }
    Property Value
    Type
    GridDataRowStylesIndexer

    TableStyle

    Gets or sets access to table styles data.

    Declaration
    public GridStyleInfoStore TableStyle { get; set; }
    Property Value
    Type
    GridStyleInfoStore

    Methods

    Clear()

    Resets the row and column count to zero and clears all cells.

    Declaration
    public virtual void Clear()

    Contains(Int32, Int32)

    Tests if the cell at the specified row and column index has been initialized.

    Declaration
    public bool Contains(int rowIndex, int colIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The row index. Can be 0 for column headers and -1 for column styles.

    System.Int32 colIndex

    The column index. Can be 0 for row headers and -1 for row styles.

    Returns
    Type Description
    System.Boolean

    True if an element is at the specified co-ordinates.

    CopyCells(GridRangeInfo, GridRangeInfo)

    Copies cell contents from a given range of cells to another range of cells.

    Declaration
    public virtual bool CopyCells(GridRangeInfo sourceRange, GridRangeInfo destRange)
    Parameters
    Type Name Description
    GridRangeInfo sourceRange

    The original range of cells that hold cell contents to be copied.

    GridRangeInfo destRange

    The target range where contents will be copied to.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    InsertCols(Int32, Int32)

    Insert a specified number of columns at a specified column index.

    Declaration
    public virtual bool InsertCols(int colIndex, int count)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The starting column index where new columns should be inserted.

    System.Int32 count

    The number of columns to insert.

    Returns
    Type Description
    System.Boolean

    true if successful; false otherwise.

    InsertRows(Int32, Int32)

    Insert a specified number of rows at a specified row index.

    Declaration
    public virtual bool InsertRows(int rowIndex, int count)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The starting row index where new rows should be inserted.

    System.Int32 count

    The number of rows to insert.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    MoveCells(GridRangeInfo, GridRangeInfo)

    Moves cell contents from a given range of cells to another range of cells.

    Declaration
    public virtual bool MoveCells(GridRangeInfo sourceRange, GridRangeInfo destRange)
    Parameters
    Type Name Description
    GridRangeInfo sourceRange

    The original range of cells that holds cell contents to be moved. This range cell contents will be cleared after the move operation is complete.

    GridRangeInfo destRange

    The target range where contents will be moved to.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    MoveCols(Int32, Int32, Int32)

    Moves a specified number of columns to a new position.

    Declaration
    public virtual bool MoveCols(int colIndex, int count, int target)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The starting column index of columns to be moved.

    System.Int32 count

    The number of columns to move.

    System.Int32 target

    The new position for the columns.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    MoveRows(Int32, Int32, Int32)

    Moves a specified number of rows to a new position.

    Declaration
    public virtual bool MoveRows(int rowIndex, int count, int target)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The starting row index of rows to be moved.

    System.Int32 count

    The number of rows to move.

    System.Int32 target

    The new position for the rows.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    RemoveCols(Int32, Int32)

    Removes a specified number of columns at a specified column index.

    Declaration
    public virtual bool RemoveCols(int colIndex, int count)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The starting column index where columns should be removed.

    System.Int32 count

    The number of columns to remove.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    RemoveRows(Int32, Int32)

    Removes a specified number of rows at a specified row index.

    Declaration
    public virtual bool RemoveRows(int rowIndex, int count)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The starting row index where rows should be removed.

    System.Int32 count

    The number of rows to remove.

    Returns
    Type Description
    System.Boolean

    True if successful; False otherwise.

    ResetModified()

    Resets the Modified flag.

    Declaration
    public void ResetModified()

    SortByColumn(Int32)

    Sorts the data object ascending by the specified column.

    Declaration
    public void SortByColumn(int colIndex)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    Examples

    This method shows how to sort a specified column with the given column index.

    this.gridControl1.Model.Data.SortByColumn(2);
    Me.gridControl1.Model.Data.SortByColumn(2)

    SortByColumn(Int32, GridRangeInfoList, ListSortDirection, IComparer)

    Sorts the data object by the specified range.

    Declaration
    public void SortByColumn(int colIndex, GridRangeInfoList range, ListSortDirection direction, IComparer comparer)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    GridRangeInfoList range

    Used to get the range list

    System.ComponentModel.ListSortDirection direction

    The sort direction: ascending or descending.

    System.Collections.IComparer comparer

    A custom comparer class that implements a CompareTo method as shown in the example.

    SortByColumn(Int32, ListSortDirection)

    Sorts the data object by the specified column.

    Declaration
    public void SortByColumn(int colIndex, ListSortDirection direction)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    System.ComponentModel.ListSortDirection direction

    The sort direction: ascending or descending.

    Examples

    This example shows how to sort a specific column with the given column index considering the sort direction.

    this.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending);
    Me.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending)

    SortByColumn(Int32, ListSortDirection, IComparer)

    Sorts the data object by the specified column.

    Declaration
    public void SortByColumn(int colIndex, ListSortDirection direction, IComparer comparer)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    System.ComponentModel.ListSortDirection direction

    The sort direction: ascending or descending.

    System.Collections.IComparer comparer

    A custom comparer class that implements a CompareTo method as shown in the example.

    SortByColumn(Int32, ListSortDirection, Int32)

    Sorts the data object by the specified column.

    Declaration
    public void SortByColumn(int colIndex, ListSortDirection direction, int extraHeaderCount)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    System.ComponentModel.ListSortDirection direction

    The sort direction: ascending or descending.

    System.Int32 extraHeaderCount

    You should pass in GridModel.Rows.HeaderCount to specify if there are additional headers displayed in the grid that should not be sorted.

    SortByColumn(Int32, ListSortDirection, Int32, IComparer)

    Sorts the data object by the specified column.

    Declaration
    public void SortByColumn(int colIndex, ListSortDirection direction, int extraHeaderCount, IComparer comparer)
    Parameters
    Type Name Description
    System.Int32 colIndex

    The column that holds the key for sorting this object.

    System.ComponentModel.ListSortDirection direction

    The sort direction: ascending or descending.

    System.Int32 extraHeaderCount

    You should pass in GridModel.Rows.HeaderCount to specify if there are additional headers displayed in the grid that should not be sorted.

    System.Collections.IComparer comparer

    A custom comparer class that implements a CompareTo method as shown in the example.

    Explicit Interface Implementations

    ICloneable.Clone()

    Declaration
    object ICloneable.Clone()
    Returns
    Type
    System.Object

    IDeserializationCallback.OnDeserialization(Object)

    Runs when the entire object graph has been de-serialized.

    Declaration
    void IDeserializationCallback.OnDeserialization(object sender)
    Parameters
    Type Name Description
    System.Object sender

    The object that initiated the callback. The functionality for this parameter is not currently implemented.

    ISerializable.GetObjectData(SerializationInfo, StreamingContext)

    Implements the ISerializable interface and returns the data needed to serialize the GridData.

    Declaration
    void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info

    A SerializationInfo object containing the information required to serialize the object.

    System.Runtime.Serialization.StreamingContext context

    A StreamingContext object containing the source and destination of the serialized stream.

    Implements

    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.Runtime.Serialization.IDeserializationCallback
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved