//By using the GridCopyContent event we can able to get the clipboardtext void SfDataGrid_GridCopyContent(object sender, GridCopyPasteEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { this.Clipboardtextbox.Text = Clipboard.GetText(); })); }
/// <summary> /// This method is called when the copy operation is initiated for the specified collection of records to clipboard for row selection. /// </summary> /// <param name="records"> /// The collection of records to initialize the copy operation. /// </param> /// <param name="canCut"> /// Indicates whether the cut operation is perform or not. /// </param> protected virtual void OnCopyingClipBoardContent(ObservableCollection <object> records, bool canCut) { GridCopyPasteEventArgs args = null; args = this.RaiseCopyContentEvent(new GridCopyPasteEventArgs(false, this.TreeGrid)); if (args.Handled) { return; } var rowDict = new SortedDictionary <int, object>(); for (int i = 0; i < records.Count; i++) { var rowindex = this.TreeGrid.ResolveToRowIndex(records[i]); if (rowindex >= 0) { rowDict.Add(rowindex, records[i]); } } var text = new StringBuilder(); var sortedRecords = (rowDict.Values).ToObservableCollection(); CopyRows(sortedRecords, ref text); #if UWP var data = new DataPackage(); #else var data = new DataObject(); #endif if (text.Length > 0) { data.SetText(text.ToString()); } if (canCut) { CutRows(sortedRecords); } #if UWP Clipboard.SetContent(data); #else Clipboard.SetDataObject(data); #endif }
/// <summary> /// To raise the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.PasteContent"/> event in SfTreeGrid. /// </summary> /// <param name="args"> /// Contains the event data. /// </param> /// <returns> /// Returns the <see cref="Syncfusion.UI.Xaml.TreeGrid.GridCopyPasteEventArgs"/>. /// </returns> protected virtual GridCopyPasteEventArgs RaisePasteContentEvent(GridCopyPasteEventArgs args) { return(TreeGrid.RaisePasteContentEvent(new GridCopyPasteEventArgs(false, this.TreeGrid))); }
private void SyncfusionGrid_GridCopyContent(object sender, GridCopyPasteEventArgs e) { MessageBox.Show("Copied"); }