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

Copy/Paste of styles

Note: using Syncfusion.Grid v1.6.1.8 I am trying to copy/paste styles at the moment and am having limited success. When I change cells like this: Me.grd(4, 4).BackColor = System.Drawing.Color.Orange Me.grd(4, 4).Text = "Test" I can copy/cut/paste the styles by default (as expected). But when I update cells like the following, only the text is cut/copy/pasted (not the styles). Dim Range As Syncfusion.Windows.Forms.Grid.GridRangeInfo Dim RangeInfo As Syncfusion.Windows.Forms.Grid.GridRangeInfoList Dim Style As Syncfusion.Windows.Forms.Grid.GridStyleInfo Dim UpdateRange As Syncfusion.Windows.Forms.Grid.GridRangeInfo Style = New Syncfusion.Windows.Forms.Grid.GridStyleInfo Style.Font.Bold = Tool.Checked grd.CurrentCell.EndEdit() If grd.Selections.GetSelectedRanges(RangeInfo, True) = True Then For Each Range In RangeInfo Select Case Range.RangeType Case Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Cells UpdateRange = Range Case Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Table UpdateRange = Range.Cells(1, 1, grd.RowCount, grd.ColCount) Case Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Rows UpdateRange = Range.Cells(Range.Top, 1, Range.Bottom, grd.ColCount) Case Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Cols UpdateRange = Range.Cells(1, Range.Left, grd.RowCount, Range.Right) End Select grd.ChangeCells(UpdateRange, Style, Syncfusion.Styles.StyleModifyType.Changes) Next End If ps. I have also tried Syncfusion.Styles.StyleModifyType.Override

8 Replies

AD Administrator Syncfusion Team September 30, 2004 05:51 AM UTC

ChangeCells seems to work OK to set styles and have them copied and pasted in the attached sample using Does this sample work for you? (If you get a syntax error when you try to compile it with, just comment out the lines with the errors.) CopyPaste_8066.zip In the debugger, have you checked the range that you are using in your ChangeCells call to make sure it is what you expect? (ModifyStyle is probably the flag you need to use.)

DE Denis September 30, 2004 09:01 PM UTC

Thanks for the quick response Clay. Your example helped me narrow the issue down. The reason why the styles arent copying across is because I have an object stored in the Tag property. See the attached example for what I mean. When you attempt a paste, the app hangs for a second or so and then just pastes the text. CopyPaste_4054.zip

DE Denis September 30, 2004 09:08 PM UTC

Note: I need the Tag property to be copied across also (with the paste operation).

DE Denis September 30, 2004 09:21 PM UTC

I have also tried to implement ICloneable for the class I am using for the Tag (thinking thats what the problem might be). It didnt make a difference :/ Public Function Clone() As Object Implements System.ICloneable.Clone Dim a As New cGridCellTag If Not m_Dependants Is Nothing Then a.m_Dependants = m_Dependants.Clone Else a.m_Dependants = Nothing End If a.Col = m_Col a.Formula = m_Formula a.FormulaExists = m_FormulaExists a.Ref = m_Ref a.Row = m_Row Return a End Function

AD Administrator Syncfusion Team September 30, 2004 09:24 PM UTC

In order to have copy/paste operations work for abitrary objects, they need to be serializable. So, in your object class definition, you should add the serializable attribute. _ Public Class cGridCellTag ......

AD Administrator Syncfusion Team September 30, 2004 09:29 PM UTC

Looks like th epointed brackets got eaten by the web posting. Here is your sample back wiyh this code change. CopyPaste_4054_3894.zip
Public Class cGridCellTag

AD Administrator Syncfusion Team September 30, 2004 09:32 PM UTC

I pasted the old project. Sorry. Here is the modified one. CopyPaste_9300.zip

DE Denis September 30, 2004 09:43 PM UTC

It worked perfectly! Thanks :)

Live Chat Icon For mobile
Up arrow icon