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

Overriding the Paste event

I''ve overridden the GridStaticCellModel to produce a image cell that displays the image in the grid and also has a dropdown. I''ve overridden the CanCut, Cut, CanCopy & Copy methods to retrieve the image directly from the cell. This works perfectly. I''ve also overridden CanPaste & Paste, but they never get called. I step through the code where the grid.Model.CutPaste.Paste() is invoked but the CanPaste & Paste in the renderer never gets called. I''ve overridden the Paste on a different cell type and it works fine. What do I need to do to get these event handlers to be invoked?

1 Reply

AD Administrator Syncfusion Team June 27, 2004 02:55 PM UTC

The cell renderer Paste/CanPaste events are only raised when the grid has an actively editing CurrentCell. Since a static cell cannot have an ''active'' cell control, these events are not raised and the grid always handles the paste itself at the grid level since there is no cell control that may need to be populated at this point. A couple of things you can try. Both involve handling the grid.Model.ClipboardPaste event in one way or the other. Try handling the event and set e.IgnoreCurrentCell = false. This may allow the renderer events to fire. (It may not depending upon the order that this event is rasied among all its listeners. But is simple to try. The second option is to handle the event and do the calls to these methods yourself.
private void gridControl1_ClipboardPaste(object sender, GridCutPasteEventArgs e)
	if(this.gridControl1.Selections.Count == 0)
		GridCellRendererBase cellRenderer = this.gridControl1.Model.CurrentCellRenderer;
		if (cellRenderer != null && cellRenderer.CanPaste() && cellRenderer.Paste())
			e.Handled = true;

Live Chat Icon For mobile
Up arrow icon