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. Image for the cookie policy date
close icon

When pasting amount, 0.01 is added into Cell

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

3 Replies

AD Administrator Syncfusion Team 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


NW Ngurah Wirawan 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


AD Administrator Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon