how to paste row as I need

I need to use ( xCopiedRow  ) as a source when I paste the row with change  RegDetRef everytime.


  private void Dgv_CopyContent(object sender, Syncfusion.WinForms.DataGrid.Events.CutCopyPasteEventArgs e)

  {

      xCopiedRow = ((e.OriginalSender as SfDataGrid).SelectedItem as MoRegDet);

  }


  private void Dgv_PasteCellContent(object sender, Syncfusion.WinForms.DataGrid.Events.CellCutCopyPasteEventArgs e)

  {

      if (e.Column.MappingName == "RegDetRef")

      {

          e.ClipboardValue = _Manager.GetRef();

      }

  }


and I want to know what the type of the copied data in ( Dgv_CopyContent ) and how to use it?



1 Reply

GS Gokul S Subramani Syncfusion Team August 26, 2024 02:18 PM UTC

Hi Aljoul,


In WinForms SfDataGrid, the CopyContent event does not provide the copied records directly. However, you can retrieve the records using the SelectedItems of the corresponding business object. If you want to get the type of the copied records directly from the CopyContent event without using SelectedItems, you can retrieve the copied records manually from the clipboard. However, it is not possible to determine the type of the copied records from the clipboard because the data is stored as plain text, which loses the original data type information. Therefore, we recommend retrieving the type from SelectedItems, or if you are performing a multiple selection, use SelectedRecords. Please refer to the code snippet below for obtaining the type of the copied records:

Code Snippet:


private void SfDataGrid1_CopyContent(object sender, Syncfusion.WinForms.DataGrid.Events.CutCopyPasteEventArgs e)

 {

     var data = (e.OriginalSender as SfDataGrid).SelectedItem as OrderInfo;

     var dataType = data.GetType();

 }


Additionally, we are a little unclear about your PasteContent event. Could you clarify what you want to do with the copied records Type in the PasteContent event?


Providing these details will help us better understand the issue and work towards finding a solution promptly.


Thank you for your understanding and cooperation.


Best Regards,

Gokul S


Loader.
Up arrow icon