Is there a simple way to copy the complete content of a data grid to the clipboard?
Hello Horst,
I am glad that you have found my suggestion helpful.
Thank you for using Infragistics components.
Thanks Tihomir,
I modified your example to keep the selection untouched and also adds the headers...
private static void CopyAllFields(XamDataGrid myGrid) { string clipboardText = ""; foreach (Field field in myGrid.FieldLayouts[0].Fields) { clipboardText += "\t" + field.Label.ToString(); } clipboardText += "\r\n"; foreach (DataRecord myRecord in myGrid.Records) { foreach (Cell cell in myRecord.Cells) { clipboardText += "\t" + cell.Value.ToString(); } clipboardText += "\r\n"; } Clipboard.Clear(); Clipboard.SetText(clipboardText); }
regards Horst
More information about WPF Commanding can be found on Microsoft Website here.
I have prepared a sample for you, in which i have created a custom command that loops through all XamDataGrid records and builds a string which is added to the clipboard.
You can use this sample to copy paste the entire grid content to an excel for an example, or use it as a foundation and modify it based on the specifics of your task.
Should you have any further questions, please let me know.
SIncerely,Tihomir TonevAssocaite Software DeveloperInfragistics
XDGAddAllToClipboard.zip
You are not very verbose...
How should this be done?
Hello,
All of the pre-defined clipboard operations of XamDataGrid do expect selection.
A copy command accepting no arguments will have to be manually implemented.
Should you have any other questions, please let me know.