Hi,
I want to copy cell
from GridDataBoundGrid.
The cell format is currency.
When I select the cell it's being a text
without format.
For Example : 1,000,123$ become 1000123
I want to copy the cell with the format - How can I do it?
(I upgrade VS from oldest version that it work well, in VS2015 it not work weel)/
Thank
Suggestion 1:
To paste the text with applied formats of “Currency” type columns, customize the Clipboard contents by using ClipboardCopy event. Please make use of the below code,
Code example:
Me.gridDataBoundGrid1.Binder.InternalColumns("Description").StyleInfo.CellType = GridCellTypeName.Currency
AddHandler Me.gridDataBoundGrid1.Model.ClipboardCopy, AddressOf Model_ClipboardCopy
Private Sub Model_ClipboardCopy(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim range As GridRangeInfo = e.RangeList.ActiveRange
Dim text As String = String.Empty
Dim data As DataObject = CType(Clipboard.GetDataObject(), DataObject)
For row As Integer = range.Top To range.Bottom
For col As Integer = range.Left To range.Right
text &= Me.gridDataBoundGrid1.Model(row, col).FormattedText
If col <> range.Right Then
text &= Constants.vbTab
End If
Next col
text &= System.Environment.NewLine
Next row
Clipboard.SetDataObject(New DataObject(text))
e.Handled = True
e.Result = True
End Sub |
Suggestion 2:
Set the format by using GridStyleInfo.Format property as like below code,
Me.gridDataBoundGrid1.Binder.InternalColumns("Description").StyleInfo.Format = "##,###$"
Me.gridDataBoundGrid1.Binder.InternalColumns("CategoryID").StyleInfo.Format = "C" |
Suggestion 3:
Set the cell type of the columns in where you want to paste the contents also as “Currency”.
Me.gridDataBoundGrid1.Binder.InternalColumns("Column2").StyleInfo.CellType = GridCellTypeName.Currency
Me.gridDataBoundGrid1.Binder.InternalColumns("Column3").StyleInfo.CellType = GridCellTypeName.Currency |
Me.gridDataBoundGrid1.Binder.InternalColumns("Description").StyleInfo.CellType = "Currency"
Query |
Response |
Unfortunately, this example doesn't work for me.
When I select the cell it's being unformatted. |
We could not able to reproduce the issue at our end. Please refer to attached video.
Can you please provide the simple video or screenshots of replication procedure of the scenario? It would be more helpful for us to analyze further on this scenario.
Video link:
|
Difference between Currency celltype and “C” format. |
The “Currency” cell type can be used to represent monetary values to achieve accuracy in the calculations. You can customize the currency cell appearance (i.e currency symbol, decimal separator, etc..) by using GridStyleInfo. Please refer to the below UG document,
|
Why in oldest version of VS it work perfectly? |
We have checked this scenario with all VS versions. But unfortunately we could not able to reproduce the issue at our end.
· Please ensure whether any assembly conflicts occurred in your project.
· Provide the Syncfusion build version details that you are using in sample. |