You can use built-in shapes in Spread for Windows Forms to draw attention to different areas of your spreadsheet. You can use shapes to show a process with flowchart-like graphics, use shapes to highlight a particular result, or use a shape for some other purpose. Spread has the following built-in shape types:

  • Basic Shapes
  • Arrow Shapes
  • Balloon Shapes
  • Special Shapes
  • Star Shapes

For a complete list of built-in shapes, refer to http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#spwin-shape-types.html. The shapes are available in code (each shape being a separate class in the DrawingSpace namespace) or from the Insert and Drawing Tools menus in the Spread Designer. Each shape can be rotated and resized, and their ability to be rotated and resized by the end user can be constrained. When selected, the shape has resize handles with which you can adjust the size and a rotate handle with which you can rotate the shape. Colors, shadows, and transparency can be adjusted. Shapes are a form of graphics that are drawn on a separate layer from that of the spreadsheet. This drawing layer, or drawing space, is in front of the spreadsheet in the display. Shapes can be made all or partially transparent to reveal the spreadsheet behind. Because the shapes appear on this separate layer from the sheet and can be thought to float above the spreadsheet, they are sometimes called floating objects. Hiding columns and rows that contain a shape hides the shape as well. The API properties that can be set for shapes are listed in the following classes:

  • FarPoint.Win.Spread.DrawingSpace.PSObject
  • FarPoint.Win.Spread.DrawingSpace.PSShape

The DynamicSize and DynamicMove properties specify how shapes are moved and resized when hiding or showing, resizing, or moving rows or columns that intersect with the shape or that appear before the shape (for example, resizing a column to the left or a row above the shape). The following options are available:

  • Move and size with cells (DynamicMove = True and DynamicSize = True)
  • Move, but do not size with cells (DynamicMove = True and DynamicSize = False)
  • Do not move or size with cells (DynamicMove = False and DynamicSize = False)

You can use the FarPoint.Win.Spread.DrawingSpace.DrawingToolbar class to bring up the shape toolbar at run time. You can use the following methods in the SheetView class to get, add, or remove shapes:

Method

Description

AddShape

Adds a shape.

RemoveShape

Removes a shape.

ClearShapes

Removes all the shapes.

GetShape

Gets a shape.

The following example shows a simple way to add a built-in shape: C#

fpSpread1.ActiveSheet.AddShape(new FarPoint.Win.Spread.DrawingSpace.RectangleShape()); 

VB

FpSpread1.ActiveSheet.AddShape(New FarPoint.Win.Spread.DrawingSpace.RectangleShape()) 

This example creates a basic rectangle shape, sets properties, and adds the shape to the active sheet. C#



// Create a new shape.  

FarPoint.Win.Spread.DrawingSpace.RectangleShape rShape = new FarPoint.Win.Spread.DrawingSpace.RectangleShape();  

// Assign a name, overriding the unique default assigned name.  

// All shape names within a sheet must be unique.  

rShape.Name = "rShape1";  

// Assign a location at which to start the display of the shape.  

rShape.Top = 20;  

rShape.Left = 60;  

// Alternatively, you could set the Location property  

// with a Point object as in:  

//rShape.Location = new System.Drawing.Point(20, 60);  

// Assign a custom fill color to the shape.  

rShape.BackColor = System.Drawing.Color.Blue;  

// Assign a size to the shape.  

rShape.Width = 100;  

rShape.Height = 100;  

// Alternatively, you could set the Size property  

// with a Size object as in:  

//rShape.Size = new System.Drawing.Size(100, 100);  

// Add the shape to the sheet so that it appears on that sheet.  

fpSpread1.ActiveSheet.AddShape(rShape);  

// This code will display the shape property dialog  

FarPoint.Win.Spread.DrawingSpace.ShapeProps f = new FarPoint.Win.Spread.DrawingSpace.ShapeProps(fpSpread1);  

f.Shape = fpSpread1.Sheets[0].DrawingContainer.GetShape("rShape1");  

f.ShowDialog(); 

VB



' Create a shape.  

Dim rShape As New FarPoint.Win.Spread.DrawingSpace.RectangleShape()  

' Assign a name, overriding the unique default assigned name.  

' All shape names within a sheet must be unique.  

rShape.Name = "rShape1"  

' Assign a location at which to start the display of the shape.  

rShape.Top = 20  

rShape.Left = 60  

' Alternatively, you could set the Location property  

' with a Point object as in:  

'rShape.Location = New Point(20, 60)  

' Assign a custom fill color to the shape.  

rShape.BackColor = Color.Blue  

' Assign a size to the shape.  

rShape.Width = 100  

rShape.Height = 100  

' Alternatively, you could set the Size property  

' with a Size object as in:  

' rShape.Size = New Size(100, 100)  

' Add the shape to the sheet so that it appears on that sheet.  

FpSpread1.ActiveSheet.AddShape(rShape)  

' This code will display the shape property dialog  

Dim f As New FarPoint.Win.Spread.DrawingSpace.ShapeProps(FpSpread1)  

f.Shape = FpSpread1.Sheets(0).DrawingContainer.GetShape("rShape1")  

f.ShowDialog() 

This example uses the drawing toolbar at run time. SpreadWinDrawingToolbar Drawing Toolbar C#

public void ShowToolbar()  
{  
FarPoint.Win.Spread.DrawingSpace.DrawingToolbar draw = default(FarPoint.Win.Spread.DrawingSpace.DrawingToolbar);  
if (fpSpread1.ActiveSheet != null)  
{  
draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(fpSpread1, fpSpread1.ActiveSheet.DrawingContainer);  
}  
else  
{  
draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(fpSpread1, null);  
}  
draw.Visible = true;  
draw.Owner = this;  
draw.Left = this.Left + this.Width - draw.Width / 2;  
draw.Top = this.Top + this.Height / 2 - draw.Height / 2;  
}  

private void button1_Click(object sender, EventArgs e)  
{  
ShowToolbar();  
}  

VB

Sub ShowToolbar()  
Dim draw As FarPoint.Win.Spread.DrawingSpace.DrawingToolbar  
If Not (FpSpread1.ActiveSheet Is Nothing) Then  
draw = New FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, FpSpread1.ActiveSheet.DrawingContainer)  
Else  
draw = New FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, Nothing)  
End If  
draw.Visible = True  
draw.Owner = Me  
draw.Left = Me.Left + Me.Width - draw.Width / 2  
draw.Top = Me.Top + Me.Height / 2 - draw.Height / 2  
End Sub  

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
ShowToolbar()  
End Sub  

You can add a built-in shape using the Insert menu in the Designer. SpreadWinDBuiltInS Shapes After you select a shape from the Shapes section, the Drawing Tools menu is displayed. SpreadWinDBuiltInDT Drawing Tools The following options are available in the Drawing Tools menu:

Item

Description

BackColor

This allows you to set the backcolor for a built-in shape.

ForeColor

This allows you to set the forecolor for a built-in shape.

OutLineColor

This allows you to set the outline color of the shape.

Thickness

This allows you to change the width of the shape outline.

OutlineStyle

This allows you to set the outline border type.

DropShadow

This allows you to specify whether to have a shadow around the edges of the shape.

Bring To Front

This allows you to specify whether to place this shape over others.

Send To Back

This allows you to specify whether to place this shape behind others.

Rotate

This allows you to select typical amounts of rotation for a shape.

Flip

This allows you to flip a shape either horizontally or vertically.

Scale

This allows you to resize a shape proportionally by selecting a scaling factor.

Set Picture

This allows you to select an image and the image properties for a built-in shape.

Clear Picture

This allows you to remove an image from a built-in shape.

Nudge

The arrows to the right side of the Drawing Tools menu allow you to move the shape.