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

How to implement a Fill Paste in the grid

Hi, I''m trying to do a ''fill paste'' - ie if you copy a single cell, and then paste into a multiple cell selection, each cell gets the value pasted. Do you have any suggestions how I might go about implementing this? Thanks, Sue

1 Reply

AD Administrator Syncfusion Team May 18, 2004 05:42 AM UTC

You can try handling this in the ClipboardPaste event.
private void gridControl1_ClipboardPaste(object sender, GridCutPasteEventArgs e)
	DataObject data = (DataObject)Clipboard.GetDataObject();
	string[] rows = null;
	int numRows = 0;
	int numCols = 0;
	//get the size of the paste
		string s = (string)data.GetData(DataFormats.Text);
		rows = s.Split(new char[]{''''});
		numRows = rows.GetLength(0);
		if(numRows > 0 && rows[numRows - 1].Length == 0)
			numRows--; //remove extra empty row if present
		if(numRows > 0)
			string[] cols = rows[0].Split(new char[]{''\t''});
			numCols = cols.GetLength(0);

	//paste one to many
	if(numRows == 1 && numCols == 1 && !this.gridControl1.Selections.Ranges.ActiveRange.IsEmpty)
		e.Handled = true;
		e.Result = true;

Live Chat Icon For mobile
Up arrow icon