When I use the Copy method in the RadGridView, the content is copied to the clipboard in multiple formats. Each format can be cancelled. If a format is cancelled it is not even serialized into the DataObject. This way a programmer can replace the copy-routine for that format with his own.
When I do the same with RadVirtualGrid, and I only want to copy format CSV and I want to cancel the rest, nothing is copied to the clipboard. The funny thing is, inspecting the code, the data is always serialized to the DataObject BEFORE the event is fired to find out if that action is needed. This is a performance penalty.
So these two behaviors are inconsistent. It is also inconsistent the the Paste-operations of both grids.
Current code:
public void CopyToClipboard(
int startRow,
int startColumn,
int endRow,
int endColumn,
VirtualGridViewInfo viewInfo,
bool selectedOnly,
bool cut)
{
DataObject dataObject = new DataObject();
string data1 = this.ProcessContent(DataFormats.Text, startRow, startColumn, endRow, endColumn, viewInfo, selectedOnly, cut);
dataObject.SetData(DataFormats.UnicodeText, false, (object) data1);
VirtualGridClipboardEventArgs args1 = new VirtualGridClipboardEventArgs(false, DataFormats.UnicodeText, dataObject, this.CurrentCell.ViewInfo);
this.OnCopying(args1);
if (args1.Cancel)
return;
dataObject.SetData(DataFormats.Text, false, (object) data1);
VirtualGridClipboardEventArgs args2 = new VirtualGridClipboardEventArgs(false, DataFormats.Text, dataObject, this.CurrentCell.ViewInfo);
this.OnCopying(args2);
if (args2.Cancel)
return;
string data2 = this.ProcessContent(DataFormats.CommaSeparatedValue, startRow, startColumn, endRow, endColumn, viewInfo, selectedOnly, cut);
dataObject.SetData(DataFormats.CommaSeparatedValue, false, (object) data2);
VirtualGridClipboardEventArgs args3 = new VirtualGridClipboardEventArgs(false, DataFormats.CommaSeparatedValue, dataObject, this.CurrentCell.ViewInfo);
this.OnCopying(args3);
if (args3.Cancel)
return;
Clipboard.SetDataObject((object) dataObject);
}
public void CopyToClipboard(
int startRow,
int startColumn,
int endRow,
int endColumn,
VirtualGridViewInfo viewInfo,
bool selectedOnly,
bool cut)
{
DataObject dataObject = new DataObject();
VirtualGridClipboardEventArgs eventArgs = new VirtualGridClipboardEventArgs(false, DataFormats.UnicodeText, dataObject, CurrentCell.ViewInfo);
OnCopying(eventArgs);
bool useText = !eventArgs.Cancel;
eventArgs = new VirtualGridClipboardEventArgs(false, DataFormats.UnicodeText, dataObject, CurrentCell.ViewInfo);
OnCopying(eventArgs);
bool useUnicodeText = !eventArgs.Cancel;
if (useText || useUnicodeText)
{
string text = __instance.ProcessContent(DataFormats.Text, startRow, startColumn, endRow, endColumn, viewInfo, cut);
if (useText)
dataObject.SetData(DataFormats.Text, false, text);
if (useUnicodeText)
dataObject.SetData(DataFormats.UnicodeText, false, text);
}
eventArgs = new VirtualGridClipboardEventArgs(false, DataFormats.Text, dataObject, CurrentCell.ViewInfo);
OnCopying(eventArgs);
if (!eventArgs.Cancel)
{
string csv = __instance.ProcessContent(DataFormats.CommaSeparatedValue, startRow, startColumn, endRow, endColumn, viewInfo, selectedOnly, cut);
dataObject.SetData(DataFormats.CommaSeparatedValue, false, csv);
}
if (dataObject.GetFormats().Length > 0)
Clipboard.SetDataObject(dataObject);
}