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

When pasting amount, 0.01 is added into Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

51832 Nov 15,2006 03:30 AM UTC Nov 15,2006 08:33 AM UTC WinForms 3
loading
Tags: GridControl
Ngurah Wirawan
Asked On November 15, 2006 03:30 AM UTC

Hi,

I am just considering why when pasting value 5, 50, 500 , 5000 ... it always adds 0.01.

I have attached simple program that can replicate the issue. Try to put on any cell of column B and try to do paste by click menu File->Paste. Amazingly it adds 0.01 to the cell.

Need advice to resolve this issue.

Regards,
Wirawan

WindowsApplication93.zip

Administrator [Syncfusion]
Replied On November 15, 2006 05:22 AM UTC

Hi Wirawan,

Please try this code snippet in Model_ClipboardPaste event and let me know if this helps.

private void Model_ClipboardPaste(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
{
IDataObject oDatVal = Clipboard.GetDataObject();
if (oDatVal.GetFormats().Length > 0)
{
Object oVal = oDatVal.GetData(oDatVal.GetFormats()[0]);
table.Rows[ gridDataBoundGrid1.CurrentCell.RowIndex - 1].BeginEdit();
table.DefaultView[gridDataBoundGrid1.CurrentCell.RowIndex - 1]["B"] = oVal;
table.Rows[ gridDataBoundGrid1.CurrentCell.RowIndex - 1].EndEdit();

e.Handled = true;
e.Result = true;
}
}

Best Regards,
Haneef

Ngurah Wirawan
Replied On November 15, 2006 06:43 AM UTC

Thanks Hannef,
but i think what make the adding of 0.01 is when we set the value to cell. For my case i have a lot of code that already used setting value directly to cell. Do you have any other idea to resolve this issue?

Regards
Wirawan

Administrator [Syncfusion]
Replied On November 15, 2006 08:33 AM UTC

Hi Wirawan,

The reason is that currentcell is in active edit state. You can try CurrentCell.Deactivate(true) method before updating/changing the currentcell. This makes sure there is not active edit state as you swap out the datasource. Here is a code snippet


IDataObject oDatVal = Clipboard.GetDataObject();
if (oDatVal.GetFormats().Length > 0)
{
Object oVal = oDatVal.GetData(oDatVal.GetFormats()[0]);
this.grid.CurrentCell.Deactivate(true);
table.DefaultView[gridDataBoundGrid1.CurrentCell.RowIndex - 1]["B"] = oVal;

e.Handled = true;
e.Result = true;
}

Best Regards,
Haneef

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

;