We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Pasting and Data Entry

Thread ID:

Created:

Updated:

Platform:

Replies:

27233 Apr 7,2005 09:05 PM UTC Apr 12,2005 03:33 PM UTC WinForms 6
loading
Tags: GridControl
Doug Finke
Asked On April 7, 2005 09:05 PM UTC

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? Thanks

Administrator [Syncfusion]
Replied On April 7, 2005 10:54 PM UTC

>>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.

Doug Finke
Replied On April 8, 2005 02:06 PM UTC

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.

Administrator [Syncfusion]
Replied On April 8, 2005 03:24 PM UTC

I am trying reproduce this problem. When I set grid[row,col].Cellvalue in Clipboardpaste, I do not see SaveCellFormattedText being raised. http://www.syncfusion.com/Support/user/uploads/GDBG_Form_2ef9bbc4.zip 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?

Administrator [Syncfusion]
Replied On April 8, 2005 07:57 PM UTC

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 ) { . . . this._grid.Binder.BeginEdit(); 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); } else { gsi.Text = newValue; } } } this._grid.Binder.EndEdit(); this._grid.Model.EndEdit(); this._grid.Model.EndUpdate(); . . . } callstack_2570.zip

Administrator [Syncfusion]
Replied On April 8, 2005 10:55 PM UTC

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.

Doug Finke
Replied On April 12, 2005 03:33 PM UTC

Thanks for the clues. I tried the CancelEdit in several places. SaveCellFormattedText is still getting called.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;