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

GridStyleInfo constructor not copying?

Hi, I want to copy a style so that I can make alterations without modifying the original style object. I thought that the copy constructor would be what was required but somethings going wrong. I call: Syncfusion.Windows.Forms.Grid.GridStyleInfo copyStyle = new Syncfusion.Windows.Forms.Grid.GridStyleInfo(style); copyStyle.ResetCellValue(); and the original style also loses its cell value. Have I done something wrong? Whats the best way to clone a GridStyleInfo object. Thanks, Sue

3 Replies

AD Administrator Syncfusion Team November 4, 2004 04:32 AM

How are you getting style? I dropped a GridControl and button on a form. In the button handler I used this code. GridStyleInfo copyStyle = new Syncfusion.Windows.Forms.Grid.GridStyleInfo(this.gridControl1[1,1]); copyStyle.ResetCellValue(); I then ran the program typed somethng into cell 1,1, and clicked the button. The value in cell 1,1 did not change. I am using Can you post a sample showing the problem?

SH Sue Harris November 4, 2004 09:38 PM

I''m getting the style as part of a SaveCellInfo event. In the case of my actual code, I''m in a OnSaveCellInfo override (of my override class of the GridControl), and it causes the cell value to be lost when the event is thrown. But it also occurs in the event itself. When I hook the SaveCellInfo event in the Virtual Grid example (no other changes) and try the following code: string cv1 = e.Style.CellValue.ToString(); GridStyleInfo a = new GridStyleInfo(e.Style); a.ResetCellValue(); string cv2 = e.Style.CellValue.ToString(); The cell value in cv2 is empty.

AD Administrator Syncfusion Team November 5, 2004 02:06 AM

I think the problem has to do with using weak references for the passed in style at this point in the code. This code avoided the problem for me. string cv1 = e.Style.CellValue.ToString(); GridStyleInfo a = new GridStyleInfo(); a.CopyFrom(e.Style); a.ResetCellValue(); string cv2 = e.Style.CellValue.ToString();

Live Chat Icon For mobile
Up arrow icon