menu

WinForms

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

    Show / Hide Table of Contents

    Class DataGridClipboardController

    Represents the clipboard operations in SfDataGrid.

    Inheritance
    System.Object
    DataGridClipboardController
    Implements
    IDataGridClipboardController
    System.IDisposable
    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.WinForms.DataGrid.Interactivity
    Assembly: Syncfusion.SfDataGrid.WinForms.dll
    Syntax
    public class DataGridClipboardController : IDataGridClipboardController, IDisposable
    Examples

    The following example shows to copy one row and paste it into all selected rows.

    // Assign the CustomGridClipboardController to DataGridClipboardController.
    sfDataGrid1.ClipboardController = new CustomGridClipboardController(sfDataGrid1);
    // Implementation for custom DataGridClipboardController.
    public class CustomGridClipboardController : DataGridClipboardController
    {
       private SfDataGrid sfDataGrid;
       public CustomGridClipboardController(SfDataGrid dataGrid)
           : base(dataGrid)
       {
           sfDataGrid = dataGrid;
       }
    
       protected override void PasteToRow(object clipBoardContent, object selectedRecords)
       {
           var text = Clipboard.GetText();
    
           string[] clipBoardText = Regex.Split(text, @"\r\n");
    
           //Get the clipBoardText and check if the clipBoardText is more than one row
           //means call the base.
           if (clipBoardText.Count() > 1)
           {
               base.PasteToRow(clipBoardContent, selectedRecords);
               return;
           }
    
           var selectedRecord = this.sfDataGrid.SelectedItems;
    
           for (int i = 0; i < selectedRecord.Count; i++)
           {
               //Get the selected records for paste the copied row.
               selectedRecords = selectedRecord[i];
    
               //Call the PasteToRow method with clipBoardContent and selectedRecords
               base.PasteToRow(clipBoardContent, selectedRecords);
           }
       }
     }

    Constructors

    DataGridClipboardController(SfDataGrid)

    Initializes a new instance of the DataGridClipboardController class.

    Declaration
    public DataGridClipboardController(SfDataGrid dataGrid)
    Parameters
    Type Name Description
    SfDataGrid dataGrid

    The instance of SfDataGrid.

    Methods

    CanConvertToType(Object, ref Type)

    Determines whether the copied cell value type is compatible with type of paste cell content.

    Declaration
    protected static bool CanConvertToType(object value, ref Type type)
    Parameters
    Type Name Description
    System.Object value

    The corresponding value can be compatible with paste cell type.

    System.Type type

    Contains type of selected column.

    Returns
    Type Description
    System.Boolean

    Returns true if the copied value type is compatible with paste cell value type; otherwise, false.

    ClearCellsByCut(ObservableCollection<Object>)

    Clears the cells by cut.

    Declaration
    protected virtual void ClearCellsByCut(ObservableCollection<object> selections)
    Parameters
    Type Name Description
    System.Collections.ObjectModel.ObservableCollection<System.Object> selections

    The selected cells or rows.

    CommitValue(Object, GridColumn, IPropertyAccessProvider, Object)

    Commits the value for the specified row data, column and corresponding changed value.

    Declaration
    protected virtual void CommitValue(object rowData, GridColumn column, IPropertyAccessProvider provider, object changedValue)
    Parameters
    Type Name Description
    System.Object rowData

    The corresponding row data to commit value.

    GridColumn column

    The corresponding column to commit value.

    IPropertyAccessProvider provider

    The corresponding provider to commit value.

    System.Object changedValue

    The corresponding changed value to commit.

    Copy()

    Copies the selected rows or current cell from SfDataGrid to clipboard.

    Declaration
    public void Copy()

    CopyCell(Object, GridColumn, ref StringBuilder)

    Copies the particular cell value for the specified column and record.

    Declaration
    protected virtual void CopyCell(object record, GridColumn column, ref StringBuilder text)
    Parameters
    Type Name Description
    System.Object record

    The corresponding record to copy the cell.

    GridColumn column

    The corresponding column to copy the cell.

    System.Text.StringBuilder text

    The corresponding copied value is append to the reference parameter.

    CopyCellRow(SelectedCellsInfo, ref StringBuilder)

    Copies the selected cells in a row using the StringBuilder.

    Declaration
    protected virtual void CopyCellRow(SelectedCellsInfo row, ref StringBuilder text)
    Parameters
    Type Name Description
    SelectedCellsInfo row

    The selected row.

    System.Text.StringBuilder text

    The string builder to copy.

    CopyCells(SelectedCellsCollection, StringBuilder)

    Copies the selected cells to the StringBuilder.

    Declaration
    protected virtual void CopyCells(SelectedCellsCollection selectedCells, StringBuilder text)
    Parameters
    Type Name Description
    SelectedCellsCollection selectedCells

    The selected cells.

    System.Text.StringBuilder text

    The string builder to copy.

    CopyRow(Object, ref StringBuilder)

    Copy operation is performed for the particular record.

    Declaration
    protected virtual void CopyRow(object record, ref StringBuilder text)
    Parameters
    Type Name Description
    System.Object record

    The corresponding record to process copy operation.

    System.Text.StringBuilder text

    The corresponding copied value is append to the reference parameter.

    CopyRows(ObservableCollection<Object>, ref StringBuilder)

    Copy operation is processed for the specified collection records.

    Declaration
    protected virtual void CopyRows(ObservableCollection<object> records, ref StringBuilder text)
    Parameters
    Type Name Description
    System.Collections.ObjectModel.ObservableCollection<System.Object> records

    The collection of record to process copy operation.

    System.Text.StringBuilder text

    The corresponding copied value is append to the reference parameter.

    CopyRowsToClipboard(Int32, Int32)

    Copies the rows to clipboard for the specified start and end of the record index.

    Declaration
    public void CopyRowsToClipboard(int startRecordIndex, int endRecordIndex)
    Parameters
    Type Name Description
    System.Int32 startRecordIndex

    The start index of the record to copy rows to clipboard.

    System.Int32 endRecordIndex

    The end index of the record to copy rows to clipboard.

    CopyTextToClipBoard(SelectedCellsCollection, Boolean)

    Copies the selected cells to clipboard.

    Declaration
    protected virtual void CopyTextToClipBoard(SelectedCellsCollection selectedCells, bool cut)
    Parameters
    Type Name Description
    SelectedCellsCollection selectedCells

    The selected cells.

    System.Boolean cut

    The value indicating whether to cut the text in selected cells or not.

    CopyTextToClipBoard(ObservableCollection<Object>, Boolean)

    Copy operation is initiated for the specified collection of records to clipboard for row selection.

    Declaration
    protected virtual void CopyTextToClipBoard(ObservableCollection<object> records, bool cut)
    Parameters
    Type Name Description
    System.Collections.ObjectModel.ObservableCollection<System.Object> records

    The collection of records to initialize copy operation.

    System.Boolean cut

    Indicates whether the cut operation is performed.

    Cut()

    Copies the selected rows or current cell and sets the default or null or empty value.

    Declaration
    public void Cut()

    CutRowCell(Object, GridColumn)

    Cut operation performed for the specified the row data and column.

    Declaration
    protected virtual void CutRowCell(object rowData, GridColumn column)
    Parameters
    Type Name Description
    System.Object rowData

    Contains the row data of the selected record to perform cut operation.

    GridColumn column

    The corresponding column of the selected record to perform cut operation.

    CutRows(ObservableCollection<Object>)

    Cut operation performed on rows in SfDataGrid.

    Declaration
    protected virtual void CutRows(ObservableCollection<object> selections)
    Parameters
    Type Name Description
    System.Collections.ObjectModel.ObservableCollection<System.Object> selections

    Contains the collection of selected records or cells based on the selection unit.

    Dispose()

    Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Disposes of the resources used by the RowGenerator.

    Declaration
    protected virtual void Dispose(bool isDispose)
    Parameters
    Type Name Description
    System.Boolean isDispose

    Indicates whether the call is from the Dispose method.

    GetPropertyType(Object, GridColumn)

    Gets the corresponding property type for the specified row data and column.

    Declaration
    protected virtual Type GetPropertyType(object rowData, GridColumn column)
    Parameters
    Type Name Description
    System.Object rowData

    The corresponding row data to get property type.

    GridColumn column

    The corresponding column to get property type.

    Returns
    Type Description
    System.Type

    Returns the corresponding property type.

    Paste()

    Pastes the clipboard copied content to the selected rows or current cell in SfDataGrid.

    Declaration
    public void Paste()

    PasteTextToCell()

    Pastes the text copied to the cell.

    Declaration
    protected virtual void PasteTextToCell()

    PasteTextToRow()

    Clipboard content is splitted into number of rows to perform paste operation for row selection.

    Declaration
    protected virtual void PasteTextToRow()

    PasteToCell(Object, GridColumn, Object)

    Pastes the copied cell value to selected cell.

    Declaration
    protected virtual void PasteToCell(object record, GridColumn column, object value)
    Parameters
    Type Name Description
    System.Object record

    Contains the record of the selected cell.

    GridColumn column

    Contains the corresponding column of the selected cell.

    System.Object value

    Contains copied cell value to paste.

    PasteToCells(Object)

    Pastes the copied cells from the clipboard to cells.

    Declaration
    protected virtual void PasteToCells(object clipboardRows)
    Parameters
    Type Name Description
    System.Object clipboardRows

    The copied clipboard rows.

    PasteToRow(Object, Object)

    Copied row is splitted into cells to perform paste operation for the specified clipboard content and selected records.

    Declaration
    protected virtual void PasteToRow(object clipboardContent, object selectedRecords)
    Parameters
    Type Name Description
    System.Object clipboardContent

    Contains the copied record to paste row.

    System.Object selectedRecords

    Contains the selected record to paste row.

    PasteToRows(Object)

    Paste operation is performed to each row of the clipboard copied rows to SfDataGrid.

    Declaration
    protected virtual void PasteToRows(object clipboardRows)
    Parameters
    Type Name Description
    System.Object clipboardRows

    Contains the copied clipboard content to paste rows.

    RaiseCopyContentEvent(CutCopyPasteEventArgs)

    Raises the event in SfDataGrid.

    Declaration
    protected virtual CutCopyPasteEventArgs RaiseCopyContentEvent(CutCopyPasteEventArgs args)
    Parameters
    Type Name Description
    CutCopyPasteEventArgs args

    Contains the event data.

    Returns
    Type Description
    CutCopyPasteEventArgs

    Returns the .

    RaiseCopyGridCellContentEvent(GridColumn, Object, Object)

    Raises the event in SfDataGrid.

    Declaration
    protected virtual CellCutCopyPasteEventArgs RaiseCopyGridCellContentEvent(GridColumn column, object rowData, object clipboardValue)
    Parameters
    Type Name Description
    GridColumn column

    The corresponding column of the cell content.

    System.Object rowData

    The corresponding row data of the cell content.

    System.Object clipboardValue

    The corresponding clipboard value that is going to be copied.

    Returns
    Type Description
    CellCutCopyPasteEventArgs

    Returns the .

    RaisePasteContentEvent(CutCopyPasteEventArgs)

    Raises the event in SfDataGrid.

    Declaration
    protected virtual CutCopyPasteEventArgs RaisePasteContentEvent(CutCopyPasteEventArgs args)
    Parameters
    Type Name Description
    CutCopyPasteEventArgs args

    Contains the event data.

    Returns
    Type Description
    CutCopyPasteEventArgs

    Returns the .

    RaisePasteGridCellContentEvent(GridColumn, Object, Object)

    Raises the event in SfDataGrid.

    Declaration
    protected virtual CellCutCopyPasteEventArgs RaisePasteGridCellContentEvent(GridColumn column, object rowData, object clipboardValue)
    Parameters
    Type Name Description
    GridColumn column

    The corresponding column of the cell content.

    System.Object rowData

    The corresponding row data of the cell content.

    System.Object clipboardValue

    The corresponding clipboard value that is going to be pasted.

    Returns
    Type Description
    CellCutCopyPasteEventArgs

    Returns the .

    Implements

    IDataGridClipboardController
    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved