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

Cut/Copy/Paste behavior in Gridcontrol

We''re trying to get a certain behavior when cutting a range of rows from a Gridcontrol. After the cut is complete, we want the grid to collapse (i.e. we want the cut rows to disappear). We added some code to do a RemoveRange on the rows after the cut. This works, but has the unfortunate side effect of clearing the clipboard. How can we remove the range and still leave the data on the clipboard for later pasting? Thanks.

4 Replies

AD Administrator Syncfusion Team April 25, 2005 09:14 PM

How are you doing this? I derived the grid and used an OnKeyDownOverride to delete the selected rows when the user type ctl+X and the clipboard was not lost with that code.
public class MyGridControl : GridControl
{
	protected override void OnKeyDown(KeyEventArgs e)
	{
		Keys keyCode = e.KeyCode & Keys.KeyCode;
		bool controlKeyDown = (Control.ModifierKeys & Keys.Control) != Keys.None;
		GridRangeInfoList rangeList = this.Selections.GetSelectedRows(true, false);
		base.OnKeyDown (e);
		if(controlKeyDown && keyCode == Keys.X && rangeList.Count > 0)
		{
			this.Rows.RemoveRange(rangeList.ActiveRange.Top, rangeList.ActiveRange.Bottom);
		}
	}
}


JE Jan Eugenides April 26, 2005 10:45 AM

Well I''m doing the removerange at the ClipboardCut event. The cut can happen with or without a keydown event so putting it in keydown won''t work, will it? >How are you doing this? I derived the grid and used an OnKeyDownOverride to delete the selected rows when the user type ctl+X and the clipboard was not lost with that code. > >
>public class MyGridControl : GridControl
>{
>	protected override void OnKeyDown(KeyEventArgs e)
>	{
>		Keys keyCode = e.KeyCode & Keys.KeyCode;
>		bool controlKeyDown = (Control.ModifierKeys & Keys.Control) != Keys.None;
>		GridRangeInfoList rangeList = this.Selections.GetSelectedRows(true, false);
>		base.OnKeyDown (e);
>		if(controlKeyDown && keyCode == Keys.X && rangeList.Count > 0)
>		{
>			this.Rows.RemoveRange(rangeList.ActiveRange.Top, rangeList.ActiveRange.Bottom);
>		}
>	}
>}
>


JE Jan Eugenides April 26, 2005 11:03 AM

Oh - as long as I''m here -- what format does the Gridcontrol put onto the clipboard?


AD Administrator Syncfusion Team April 28, 2005 04:13 PM

Text/Unicode Format and also an internal format (a GridData object). You can control this with ClipboardFlags (see GridDragDropFlags.Text and GridDragDropFlags.Styles) Stefan >Oh - as long as I''m here -- what format does the Gridcontrol put onto the clipboard?

Loader.
Live Chat Icon For mobile
Up arrow icon