Hi,
I have a question regarding paste operation in the grid.
In the grid, I have one field with string[] type object. I set IsExpandable to be false so the cell is not displayed in another field layout. I used an adorning editor. Everything is working fine to this point.
When I copy value from a cell in this field and paste into another cell in the field, in my ClipboardPasting event, I have following code:
private void MainGrid_ClipboardPasting(object sender, ClipboardPastingEventArgs e) { for (var column = 0; column < e.FieldCount; column++ ) { for (var row = 0; row < e.RecordCount; row++) { var field = e.GetTargetField(column); if (field.Name.Equals("MyArrayColumn")) { var cell = e.GetTargetCell(row, column); var cvh = e.Values[cell]; } } } }
I noticed cell.Value contains the value of the cell before pasting, however, cvh.Value is not the string[] value of the source cell, instead, it is a string with value "String[] Array". In my debugger, I can see cvh is actually a ClipboardCellValueHolder and it contains original value of a string[] which is what I need. But since ClipboardCellValueHolder is internal, I cannot cast cvh to it and cannot get source string[] value.
Please advice,
Thank you!
Yu
Hello Yu,
It has been a while since you have made your post, in case you still need of support I will be glad to assist you on this. I suppose the other community members can benefit from this answer as well. So I researched your issue and I would suggest you get the cell value before pasting by handling the EditModeEdning or CellUpdating events of the XamDataGrid instead of getting it in ClipboardPasting. To achieve this you can try:
string before;
private void grid_EditModeEnding(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndingEventArgs e)
{
before = e.Cell.Value.ToString();
}
If you need any further assistance on this, please do not hesitate to ask.