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

copying GridStyleInfo

Hi, I have several small GridControls with just a few rows each. They contain lots of formatting, comboboxes, checkboxes etc. At runtime, I need to create a large GridControl using the small ones as a source i.e. by repeatedly copying the cells from the small grids to the large. The large grid may end up with thousands of rows. I tried using GridStyleInfo.CopyFrom(), but it was slow, and didn''t seem to handle some of the cells (checkboxes, combos''s etc.) properly. I also tried instantiating new GridStyleInfo''s using the source GridStyleInfo as an argument to the constructor. That was much faster, but I must be doing something wrong, because the new cells seem "connected" to the old (ie if I enter a value in the cell, it affects the cell I used as a source). Do you think this is the best approach to the problem - if so, what am I doing wrong? Thanks, Andy

1 Reply

AD Administrator Syncfusion Team January 27, 2005 06:21 AM

You might try using these two methods to copy data from one grid and then move it into another. this.gridControl1.DataExchange.CopyCellsToDataObject this.gridControl1.DataExchange.PasteCellsFromDataObject Here is a little snippet that moves 1 grid to another. You would have to set the paste row/col to move to the proper location.
private void button1_Click(object sender, System.EventArgs e)
{
	GridData data = new GridData();
	int rowCount, colCount;
	GridRangeInfo range = GridRangeInfo.Table();
	range = range.ExpandRange(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount);
	this.gridControl1.DataExchange.CopyCellsToDataObject(out data, range, false, GridDragDropFlags.Styles, out rowCount, out colCount);
	this.gridControl2.DataExchange.PasteCellsFromDataObject(data, GridRangeInfo.Cell(1,1), true, GridDragDropFlags.Styles);
}

Loader.
Live Chat Icon For mobile
Up arrow icon