Skip to main content Skip to footer

GrapeCity Spread Silverlight CTP, Part 12 - Drag and Fill

Spread CTP - Script 12: Drag and Fill

If you are interested in downloading the Spread CTP, please email labs@grapecity.com .

This is the 12th 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
Part 7 : Clipboard Operation
Part 8 : Conditional Formatting
Part 9 : CSV Import and Export
Part 10: Data Binding
Part 11: Drag and Move

GcSpreadSheet has a drag fill option that allows the user to select cells and fill other cells with the same or different values. The fill type can be set to linear, growth, date, or automatic fill. The fill direction can also be specified. Additional options can be set such as step and stop values.

Select a cell or block and move the mouse pointer over the square at the corner of the selection. The mouse pointer changes to a double arrow that can be used to expand the fill range. Click on the plus mark to display a menu with additional fill options as shown in the following image:

clip_image001

Drag fill is not supported if the destination range contains a spanned cell. Drag fill does not apply to a conditional format or filtered range.

The AllowDragFill property is used to specify whether to allow drag fill. The FillAuto Method, FillDate Method, FillGrowth Method, or FillLinear Method can be used to programmatically specify the type of fill.

Using Code

CS

gcSpreadSheet1.AllowDragFill = true;
gcSpreadSheet1.Sheets[0].SetValue(0, 0, new DateTime(2011, 1, 1));
gcSpreadSheet1.Sheets[0].SetValue(0, 1, new DateTime(2011, 2, 9));
gcSpreadSheet1.Sheets[0].SetValue(0, 2, 5);
gcSpreadSheet1.Sheets[0].SetValue(0, 3, 10);
gcSpreadSheet1.Sheets[0].SetValue(0, 4, 1);
gcSpreadSheet1.Invalidate();

private void button1_Click(object sender, RoutedEventArgs e)
{
GrapeCity.Windows.SpreadSheet.Data.CellRange r = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 4, 1);
gcSpreadSheet1.Sheets[0].FillDate(r, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, GrapeCity.Windows.SpreadSheet.Data.FillDateUnit.Day, 2);
GrapeCity.Windows.SpreadSheet.Data.CellRange r2 = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 1, 4, 1);
gcSpreadSheet1.Sheets[0].FillDate(r2, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, GrapeCity.Windows.SpreadSheet.Data.FillDateUnit.Day, 1, new DateTime(2011, 2, 11).ToOADate());
GrapeCity.Windows.SpreadSheet.Data.CellRange r3 = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 2, 4, 1);
//gcSpreadSheet1.Sheets[0].FillAuto(r3, GrapeCity.Windows.SpreadSheet.Data.FillDirection.Down);
gcSpreadSheet1.Sheets[0].FillAuto(r3, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column);
GrapeCity.Windows.SpreadSheet.Data.CellRange r4 = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 3, 4, 1);
//gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column);
//gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 2);
gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 2, 55);
GrapeCity.Windows.SpreadSheet.Data.CellRange r5 = new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 4, 4, 1);
//gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column);
//gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 3);
gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 3, 20);
gcSpreadSheet1.Invalidate();
}

VB.NET

GcSpreadSheet1.AllowDragFill = True
GcSpreadSheet1.Sheets(0).SetValue(0, 0, New DateTime(2011, 1, 1))
GcSpreadSheet1.Sheets(0).SetValue(0, 1, New DateTime(2011, 2, 9))
GcSpreadSheet1.Sheets(0).SetValue(0, 2, 5)
GcSpreadSheet1.Sheets(0).SetValue(0, 3, 10)
GcSpreadSheet1.Sheets(0).SetValue(0, 4, 1)
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, 4, 1)
GcSpreadSheet1.Sheets(0).FillDate(r, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, GrapeCity.Windows.SpreadSheet.Data.FillDateUnit.Day, 2)
Dim r2 As New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 1, 4, 1)
GcSpreadSheet1.Sheets(0).FillDate(r2, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, GrapeCity.Windows.SpreadSheet.Data.FillDateUnit.Day, 1, New DateTime(2011, 2, 11).ToOADate())
Dim r3 As New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 2, 4, 1)
'GcSpreadSheet1.Sheets(0).FillAuto(r3, GrapeCity.Windows.SpreadSheet.Data.FillDirection.Down)
GcSpreadSheet1.Sheets(0).FillAuto(r3, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column)
Dim r4 As New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 3, 4, 1)
'GcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column)
'GcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 2)
GcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 2, 55)
Dim r5 As New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 4, 4, 1)
'GcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column)
'GcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 3)
GcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Windows.SpreadSheet.Data.FillSeries.Column, 3, 20)
GcSpreadSheet1.Invalidate()
End Sub

Part 13 : Edit Mode and Frozen Columns and Rows

Technorati Tags: Spread,Excel,Silverlight,CTP,labs@grapecity.com,visual studio,AutoFit,borders and Grid lines,cell format,cell overflow,cell span,clipboard,clipboard operation,conditional formatting,CSV,CSV Import and Export,data binding,drag and move,drag and fill

tweetmeme_url = 'http://www.clubfarpoint.com/Forums/blogs/russells\_blog/archive/2012/04/26/grapecity-spread-silverlight-ctp-part-12-drag-and-fill.aspx'; tweetmeme_source = '@russcamtv'; tweetmeme_hashtags = '#appdev';

MESCIUS inc.

comments powered by Disqus