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

Copy/Paste of styles

Thread ID:





19603 Sep 29,2004 11:23 PM UTC Sep 30,2004 09:43 PM UTC WinForms 8
Tags: GridControl
Asked On September 29, 2004 11:23 PM UTC

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

Administrator [Syncfusion]
Replied On 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.)

Replied On 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

Replied On September 30, 2004 09:08 PM UTC

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

Replied On 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

Administrator [Syncfusion]
Replied On 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 ......

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On September 30, 2004 09:32 PM UTC

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

Replied On September 30, 2004 09:43 PM UTC

It worked perfectly! Thanks :)


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon