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

Copy/Paste grid cell with custom data

Thread ID:





48852 Sep 5,2006 02:52 PM UTC Sep 11,2006 02:23 PM UTC WinForms 4
Tags: GridControl
Thomas Stubbe Teglbjaerg
Asked On September 5, 2006 02:52 PM UTC


While using a GridControl component I am trying to maintain a reference between each grid cell (GridStyleInfo object) and a underlying cell model of my of design (Class ModelCell).

I have tried to do this by setting a reference in the GridStyleInfo.Tag field of each cell, so it points to the correct underlying ModelCell.

This works well until I use the copy-paste features of the gridControl instance. The problem is that the GridStyleInfo.Tag field is copied along with all the other state in the GridStyleInfo object - thereby overwriting the ModelCell reference of the destination GridStyleInfo.Tag.

In other words: Several GridStyleInfo.Tag fields end up referencing the same ModelCell, while some ModelCells are left unreferenced.

My question is: Is it possible for the copy/paste functions to ignore the GridStyleInfo.Tag field (not likely), or alternatly - does anybody know of a way to maintain such a connection as described above.

Regards, Thomas.

Administrator [Syncfusion]
Replied On September 7, 2006 03:11 PM UTC

I tried to reproduce the problem in this sample, but could not using version 4.2. What version of our libraries are you using?


Are you doing anything different than what the sample does?

Thomas Stubbe Teglbjaerg
Replied On September 8, 2006 12:24 PM UTC

Thank you for the reply !

Sorry i forgot to mention we are using VS. 2005, .NET 2.0 runtime and Essential Studio v. as out development platform.

I''ve tried your example (*) and it runs as I would expect it to, that is; references to ModelCells which are keept in the Tag fields are _not_ copied while performing copy-paste operations in the grid, thereby maintaning the references to the ModelCells correctly.

Further investigation reveals that when the ModelCell class is marked with the [Serializeable] attribute - as our ModelCell class is - the Tag field of the target GridStyleInfo object is set to null after
performing a paste operation.

Is this by design ? If so do you how this is normally handled ?

Do i understand it correctly if i assume the Tag field of the GridStyleInfo object is _not_ to be copied ?

Another thing i''ve noticed playing around with your example, is that GetObjectData() is never called when even though i''ve explicitly told ModelCell to implement ISerializable (ie, ModelCell : ISerializable). This is not the case if ModelCell i _also_ tagged with the [Serializeable] attribute - in that case GetObjectData() is called when pasting into the grid.

- Thomas

(*) I had to comment our the line:

this.gridControl1.SerializeCellsBehavior =

to make it compile - but figured it wasn''t relevant to the problem at hand.

Administrator [Syncfusion]
Replied On September 9, 2006 09:29 AM UTC

We are still working on this. There may be something broken in the style.ModifyStyle code.

But if all you need to do is to copy/paste values among the cells (and not copy other cell aspects like backcolor, etc.), then you can just tell the grid to copy the text. This will avoid affecting the Tag values which is what you are looking for. You can tell the grid to only copy text using this property setting.

this.gridControl1.CutPaste.ClipboardFlags &= ~GridDragDropFlags.Styles;

If you really do need to copy all style properties except the tag, this can be done by handling an event like ClipboardPaste and doing the work yourself avoiding the library style-paste code.

Thomas Stubbe Teglbjaerg
Replied On September 11, 2006 02:23 PM UTC

Thanx for the tip.

I''ll give that a try.

- Thomas


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