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

GridControl Cut and Insert

Hi, How can we cut and insert the row or rows in the Gridcontrol.(Behavior same like excel) If there is any sample application pls share regards Pratiksha

5 Replies

AD Administrator Syncfusion Team May 30, 2005 09:29 AM

By default, you can mouse down and select a range of cells. Once the cells are selected, you can press ctl+C to copy them, and ctl+X to cut them. You can then paste them into Excel or any other application that accepts a text from the clipboard.


AD Administrator Syncfusion Team May 30, 2005 09:46 PM

Can you pls tell how can we do that programatically. on the context menu option cut i was them to cut (just like excel) and when insert context menu is clicked i want selected cut rows to remove from the original position and inserted at the new positions >By default, you can mouse down and select a range of cells. Once the cells are selected, you can press ctl+C to copy them, and ctl+X to cut them. You can then paste them into Excel or any other application that accepts a text from the clipboard. > >


AD Administrator Syncfusion Team May 31, 2005 03:22 AM

You can call these methods in a GridControl. gridControl1.CutPaste.Copy gridControl1.CutPaste.Paste gridControl1.CutPaste.Cut In a GridDataBoundGrid, the CutPaste object is a member of the gridDataBoundGrid1.Model.


AD Administrator Syncfusion Team May 31, 2005 11:02 PM

Can you pls suggest method for adding the rows and deleting the rows in the Gridcontrol... so that the copied contents can be pasted in the newly inserted rows >You can call these methods in a GridControl. > >gridControl1.CutPaste.Copy >gridControl1.CutPaste.Paste >gridControl1.CutPaste.Cut > >In a GridDataBoundGrid, the CutPaste object is a member of the gridDataBoundGrid1.Model.


AD Administrator Syncfusion Team June 1, 2005 04:19 AM

To insert rows and/cols, you will need to call grid.Rows.InsertRange and grid.Cols.InsertRange. To decide how many rows/columns you need to insert, you will have to get the data from the Clipboard and see how big the paste is. Here is a code snippet.
DataObject data = (DataObject) Clipboard.GetDataObject();

if(data.GetDataPresent(DataFormats.Text))

{

	string s = (string)data.GetData(DataFormats.Text);

	string[] rows = s.Split(new char[]{''''});

	int numRows = rows.GetLength(0);

	if(numRows > 0 && rows[numRows - 1].Length == 0)

		numRows--; //remove extra empty row if present

		int numCols = 0;

	if(numRows > 0)

	{

		string[] cols = rows[0].Split(new char[]{''\t''});

		numCols = cols.GetLength(0);

	}

	Console.WriteLine("{0} rows by {1} cols", numRows, numCols);

}

Loader.
Live Chat Icon For mobile
Up arrow icon