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

Count of Cut/Copied Row

How do I get the number of rows that have been cut/copied? I need to know this when pasting (I''m doing a Paste Insert) so I can insert the correct number of rows first.

1 Reply

AD Administrator Syncfusion Team October 4, 2004 07:19 AM UTC

Here is code that gets the size of the paste in the ClipboardPaste event.
private void gridControl1_ClipboardPaste(object sender, GridCutPasteEventArgs e)
{
	DataObject data = (DataObject) Clipboard.GetDataObject();
	if(data.GetDataPresent(DataFormats.Text))
	{
		string s = (string)data.GetData(DataFormats.Text);
		string[] rows = s.Split(new char[]{''\n''});
		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