GrapeCity Spread Silverlight CTP, Part 7 - Clipboard Operation
Spread CTP - Script 7: Clipboard Operation
If you are interested in downloading the Spread CTP, please email labs@grapecity.com .
This is the 7th in a series of Spread CTP Blogs and is a continuation of:
Part 1 : Create an app from scratch
Part 2 : AutoFit
Part 3 : Borders and Grid Lines
Part 4 : Cell Format
Part 5 : Cell Overflow
Part 6 : Cell Span
The user can cut, copy, and paste data in the control by default. You can set AutoClipboard to false to prevent this. The ClipBoardOptions property allows you to control what data is pasted by the user. If the user cuts the data before pasting, all the information is pasted.
The cut action is treated as a copy action if the user cuts the data between controls, between the control and an Excel-formatted file, or between the GcSpreadSheet control and other controls.
Copying and pasting between the control and a CSV file is only supported if the text is separated with /t.
The following conditions apply when using cut, copy, or paste:
· If a selected range includes a hidden cell, then the hidden cell information is cut, copied, or pasted as well.
· The active cell becomes the first cell of the target range when pasting.
· Text is treated as a formula when pasting text that starts with an "=" from another control or application.
· Cut, copy, or paste is not supported with data validation, conditional formats, and filter actions.
· Cut, copy, or paste is not supported between the control and an HTML file.
· The target range size may be adjusted to the source range size when copying and pasting.
Add a button to the page for “Copy and Paste”:
Using Code
CS
gcSpreadSheet1.AutoClipboard = true;
gcSpreadSheet1.ClipBoardOptions = GrapeCity.Windows.SpreadSheet.Data.ClipboardPasteOptions.All;
gcSpreadSheet1.Sheets[0].Cells[0, 0].Value = "Copy";
gcSpreadSheet1.Sheets[0].Cells[1, 1].Value = "Cut";
gcSpreadSheet1.Invalidate();
private void button1_Click(object sender, RoutedEventArgs e)
{
GrapeCity.Windows.SpreadSheet.Data.CellRange r;
r = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 2, 2);
GrapeCity.Windows.SpreadSheet.Data.CellRange r2;
r2 = new GrapeCity.Windows.SpreadSheet.Data.CellRange(3, 3, 2, 2);
GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet test;
test = gcSpreadSheet1;
test.View.ClipboardCopy(r);
//test.View.ClipboardCut(r);
test.View.ClipboardPaste(r2);
gcSpreadSheet1.Invalidate();
}
VB.NET
GcSpreadSheet1.AutoClipboard = True
GcSpreadSheet1.ClipBoardOptions = GrapeCity.Windows.SpreadSheet.Data.ClipboardPasteOptions.All
GcSpreadSheet1.Sheets(0).Cells(0, 0).Value = "Copy"
GcSpreadSheet1.Sheets(0).Cells(1, 1).Value = "Cut"
GcSpreadSheet1.Invalidate()
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim r As New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 2, 2)
Dim r2 As New GrapeCity.Windows.SpreadSheet.Data.CellRange(3, 3, 2, 2)
Dim test = GcSpreadSheet1
test.View.ClipboardCopy(r)
'test.View.ClipboardCut(r)
test.View.ClipboardPaste(r2)
GcSpreadSheet1.Invalidate()
End Sub
Run the app and click on the button and say Yes to the prompt
Part 8 Conditional Formatting
Spread, Excel, Silverlight, CTP, labs@grapecity.com , visual studio, AutoFit, borders and Grid lines , cell format, cell overflow, cell span, clipboard, clipboard operation
tweetmeme_url = 'http://www.clubfarpoint.com/Forums/blogs/russells\_blog/archive/2012/03/28/grapecity-spread-silverlight-ctp-part-7-clipboard-operation.aspx'; tweetmeme_source = '@russcamtv'; tweetmeme_hashtags = '#appdev';