We are using the databound grid.
Two events are used ClipboardPaste and SaveCellFormattedText.
In the ClipboardPaste event data is taken from the clipboard acted on and placed back into the GridStyleInfo CellValue.
The SaveCellFormattedText event gets call afterward. This event uses the GridCellTextEventArgs Text property to retrieve data.
These GridStyleInfo CellValue and GridCellTextEventArgs Text do not have the same values.
Is there a method I can call in the ClipboardPaste event to flush the updates so that the GridCellTextEventArgs Text property reflect the same value?
ADAdministrator Syncfusion Team April 7, 2005 05:54 PM
>>In the ClipboardPaste event data is taken from the clipboard acted on and placed back into the GridStyleInfo CellValue.
Not sure what GridStyleInfo object you are referring to here. The GridCutPasteEventArgs does not actually pass any GridStyleInfo objects, does it?
Are you looping through and setting grid[row, col].CellValue? A couple of things to try. You could try setting grid.binder.DirectSaveCellInfo = true to see if this will affect this behavior. Another option would be to call grid.Binder.BeginEdit and grid.Binder.EndEdit around setting this value to see if that does anything.
DFDoug FinkeApril 8, 2005 09:06 AM
I am looping through the selected range on a Paste.
grid[row, col] returns a GridStyleInfo.
I set the GridStyleInfo.CellValue to the new value.
This works, I do Binder.EndEdit etc.
The problem I have is, the SaveCellFormattedText gets called, and it looks a its GridCellTextEventArgs Text value. Which is the actual value that is visible in the control on the screen.
The value set in the ClipboardPaste event does not bubble up to the actual control.
SaveCellFormattedText needs what is in the actual control for when the user types in it.
I think I need to either stop the SaveCellFormattedText event to not fire or in the ClipboardPaste to update the actual control.
ADAdministrator Syncfusion Team April 8, 2005 10:24 AM
I am trying reproduce this problem. When I set grid[row,col].Cellvalue in Clipboardpaste, I do not see SaveCellFormattedText being raised.
In the sample, select a range of cells, and just press ctl+V to paste. The code just explicilty sets some values into the cells through the indexer on the grid. What is different about what you are doing?
In Clipboardpaste, are you setting e.Cancel = true so the data does not get pasted twice?
ADAdministrator Syncfusion Team April 8, 2005 02:57 PM
Here is the routine called from the event responding to the ClipboardPaste.
The attached bmp shows the call stack.
private void ApplyValueToSelectedCells ( string newValue, GridCutPasteEventArgs e )
for(int row = range.Top; row <= range.Bottom; ++row)
for(int col = range.Left; col <= range.Right; ++col)
GridStyleInfo gsi = this._grid[row, col];
ColumnStyleTag tag = gsi.Tag as ColumnStyleTag;
if ((tag != null) && (tag.Converter != null))
gsi.CellValue = tag.Converter.Parse(gsi.Format, newValue, gsi.CellValueType, gsi.CultureInfo);
gsi.Text = newValue;
ADAdministrator Syncfusion Team April 8, 2005 05:55 PM
Before doing your code in ClipboardPaste, try calling grid.CurrentCell.CancelEdit. From your callstack, the SaveCellFormattedText is being triggerred by the CurrentCellConfirmChanges call triggerred by the model.EndEdit call. But since you are pasting new information into the currentcell, the initial open edit does not need to ne confirmed. The CancelEdit call is an attempt to try to avoid this ConfirmChanges. You code is setting values directly into the grid, and is really not related to having a currentcell. I think it is the old current cell that is causing this SaveCellFormattedText call. If that is the case, then SaveCellFormattedText would only be hit for the currentcell in the paste and not for every cell in the paste. This would also explian why the ''old'' e.text value is still around as this is coming from the cellrenderer that was initiallized with teh style before the paste.
DFDoug FinkeApril 12, 2005 10:33 AM
Thanks for the clues. I tried the CancelEdit in several places. SaveCellFormattedText is still getting called.