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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to capture cell value changes after copy/paste

Thread ID:

Created:

Updated:

Platform:

Replies:

71914 Feb 20,2008 03:35 PM UTC Feb 25,2008 03:13 PM UTC Windows Forms 4
loading
Tags: GridControl
Frank
Asked On February 20, 2008 03:35 PM UTC

Hi,

I'm using gridControl 4.4.0.51, and I catch CurrentCellChanged event to do something when the value in a specific cell has been changed. However, if users copy some values and paste to several cells which include the cell i'm interested in, then the CurrentCellChanged event is not fired. I tried CellChanged event as well, but it didn't work either.

So, basically how can I capture a cell value change when use copies and pastes to the grid?

Thanks,

Frank
UBS, Mortgage IT


Administrator [Syncfusion]
Replied On February 21, 2008 11:23 AM UTC

Hi Frank,

You can capture the value changed when user copies and pastes to the grid by using GridCutPasteEventArgs. The following code snippet shows how you can capture value changed.


bool b = true; // class level variable
private void gridControl1_ClipboardCut(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
{
if(this.b)
{
e.Handled = true;
this.b = !this.b;
Console.WriteLine("gridControl1_ClipboardCut");
}
}


Please refer the sample in the below link which illustrates the above.

http://websamples.syncfusion.com/samples/Tools.Windows/F71941/main.htm”

Let us know if this is not what you needed.

Regards,
Asem.



Frank
Replied On February 21, 2008 05:07 PM UTC

Asem,

Thanks for your reply, but this approach doesn't solve my problem.

gridControl1_ClipboardPaste is raised BEFORE the values are set in the cells, which means I won't be able to read the value that user copy and paste to the cells from the event handler.

What I need is this: when user copy and paste some values from somewhere, let's say 10 values from an excel spreadsheet column to the grid, then 10 cells on the grid will be set with some values. If the fifth cell on this column is set to a certain value, say 888, then I need to do something about it.

Normally, if the user edits the cell directly, i can just handle the CurrentCellChanged event, but if the user copies and pastes, then how I can capture that?

Thanks,

Frank


Administrator [Syncfusion]
Replied On February 25, 2008 06:18 AM UTC


Hi Frank,

If you want to read the value that user paste to the cells, you can use SaveCellInfo instead of ClipboardPaste.
SaveCellInfo is fired after the content of a cell is changed. You can use the SaveCellInfor as follows.


[C#]
void GridSaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
if( e.ColIndex > 0 && e.RowIndex > 0)
{
// Store data back to the datasource from the grid cell.
this._extData[e.RowIndex - 1, e.ColIndex - 1] = int.Parse(e.Style.CellValue.ToString());
e.Handled = true;
}
}


Kindly have a look at the sample in the below link which implements the above work around.

http://websamples.syncfusion.com/samples/Grid.Windows/F71914_A/main.htm


Please let me know if you have any queries.

Regards,
Asem.



Frank
Replied On February 25, 2008 03:13 PM UTC

It works. Thanks.



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

;