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.
Unfortunately, activation email could not send to your email. Please try again.

How to implement a Fill Paste in the grid

Thread ID:

Created:

Updated:

Platform:

Replies:

14067 May 17,2004 09:23 PM May 18,2004 01:42 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 17, 2004 09:23 PM

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

Administrator [Syncfusion]
Replied On May 18, 2004 01:42 AM

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
	if(data.GetDataPresent(DataFormats.Text))
	{
		string s = (string)data.GetData(DataFormats.Text);
		rows = s.Split(new char[]{''\n''});
		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)
	{
		this.gridControl1.ChangeCells(this.gridControl1.Selections.Ranges.ActiveRange,
			rows[0]);
		e.Handled = true;
		e.Result = true;
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;