[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Collapse]Charts and Graphics
     Charting Overview
     Create and Modify a Chart Programmatically
     Shapes
     Pictures
    Printing
    Events
    Protection
    Operation Restrictions
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Shortcuts
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Charts and Graphics

This document provides information about embedded drawing objects - shapes, pictures and charts.

Actions covered here:

Expanded Create a Drawing Object

The Shape interface is a base interface for all drawing objects. They are stored in the ShapeCollection collection, accessible by the Worksheet.Shapes property.

Note

Pictures and charts are contained in two collections: ShapeCollection and PictureCollection or ChartCollection, respectively.

Use the Shape.ShapeType property to determine a drawing object's type in ShapeCollection.

The table below lists the supported drawing object types and methods used to create them.

Drawing Object Method
Shape ShapeCollection.AddShape
Shape Group ShapeCollection.GroupShapes
Text Box ShapeCollection.AddTextBox
Shape Connector ShapeCollection.AddConnector
Picture PictureCollection.AddPicture
Chart ChartCollection.Add

Expanded Move and Position a Drawing Object

Use an API from the table below to define a drawing object's location.

API Description
FloatingObject.Move Moves a floating object by a specified offset.
FloatingObject.Left Gets or sets the distance from the left edge of the worksheet to the top left corner of the drawing object.
FloatingObject.OffsetX Specifies a distance between the top left corner of the floating object and the left edge of the cell where the top left corner of the floating object is located.
FloatingObject.Top Defines the distance between the top edge of the worksheet and the top left corner of the floating object.
FloatingObject.OffsetY Gets a distance between the top left corner of the floating object to the top edge of the cell where the top left corner of the floating object is located.
FloatingObject.TopLeftCell Specifies a cell where the top left corner of a floating object is located.
FloatingObject.BottomRightCell Gets or sets a cell where the bottom right corner of a floating object is located.
Shape.ZOrderPosition Retrieves the position of the current drawing object in the Z-order. The default shapes' Z-order value is equal to their numerical order in the ShapeCollection.
ShapeCollection.NormalizeZOrder Resets the shapes' Z-order.

The image below illustrates the distances this API specifies.

Expanded Resize and Rotate a Drawing Object

You can specify the drawing object's size and rotation angle using the following properties.

End-users can resize or rotate a drawing object with special handles, which are visible for selected objects.

The FloatingObject.Placement property determines whether the drawing object moves and/or resizes together with underlying cells. For example, set the Placement property to Placement.MoveAndSize to make the drawing object move and resize with cells, as shown below.

Expanded Associate a Drawing Object with a Hyperlink

You can provide a hyperlink to the drawing object. When an end-user clicks the drawing object, the link navigates to a certain location on the Internet, to a file, to a place in a workbook, or it sends an email. Use the Shape.InsertHyperlink method to specify a hyperlink for a drawing object. Use the Shape.RemoveHyperlink method to delete a hyperlink. Refer to the How to: Add a Hyperlink to a Picture topic for a code example.

Expanded Delete a Drawing Object

The following methods allow you to remove a drawing object.

Expanded Implement End-User Restrictions

The SpreadsheetControl allows you to prevent users from modifying drawing objects embedded in a worksheet. Use the following properties to implement end-user restrictions.

  • SpreadsheetControl.Options.DocumentCapabilities
Property Description
SpreadsheetCapabilitiesOptions.Pictures Specifies whether end-users can load, insert, and export pictures.
SpreadsheetCapabilitiesOptions.Charts Specifies whether end-users can load, insert, and export charts.
SpreadsheetCapabilitiesOptions.Shapes Specifies whether end-users can load and export shapes.
  • SpreadsheetControl.Options.Behavior.Drawing
Property Description
SpreadsheetDrawingBehaviorOptions.Move Specifies whether end-users can change the position of drawing objects.
SpreadsheetDrawingBehaviorOptions.Resize Specifies whether end-users can change the size of drawing objects.
SpreadsheetDrawingBehaviorOptions.Rotate Specifies whether end-users can rotate drawing objects.
SpreadsheetDrawingBehaviorOptions.ChangeZOrder Specifies whether end-users can change the order of drawing objects in a worksheet.

Set the desired property to DocumentCapability.Disabled or DocumentCapability.Hidden to make the operation unavailable, and disable or hide the corresponding commands in the SpreadsheetControl's ribbon UI and popup menu.

Expanded See Also

Is this topic helpful?​​​​​​​