I would like to clone a UltraGridRow into a new instance of UltraGridRow and change the value of few cells only. Then I would like to add this new UltraGridRow instance to my Band.
I am seeking a way to not have to go through each Cell one by one to copy them into the new instance.
Is there any intelligent and effective way to do this?
Many Thanks
Hi,
There's no way to do this without looping through the fields. Although, I would probably do it on the data source, rather than on the grid.
Hi Mike,
Is there any simple solution to copy few cells from one row to another row using C# code.
The original query is from 2009 so thought there might be some new functions by now. Also I could not find the UltraGridRow.CopyFrom() method.
CopyFrom
Thanks.
No, nothing new has been added to the grid that would help with this. You basically have to loop through the fields and create a new row with the same values. As I mentioned above, it's probably easiest to do this on the DataSource, rather than trying to programmatically do it through the UI.
The grid has no CopyFrom method (which is why you can't find it).
The grid does have Copy and Paste functionality, which you can turn on via the AllowMultiCellOperation property on the Override.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridOverride ov = layout.Override; ov.AllowMultiCellOperations = AllowMultiCellOperation.All; }
This allows the user to cut, copy, paste, delete, undo and redo values in the selected cells. You could also simulate this user interaction using the PerformAction method on the grid. But this is probably not a good idea for several reasons. First, it would require you to programmatically change the selected rows. Second, it's going to use the system keyboard, which would blow away anything the user had already copied there.