Skip to main content

How to: Add a Hyperlink to a Picture

This example demonstrates how to associate a hyperlink with a picture using the following API.

Member Description
PictureCollection.AddPicture Inserts a picture from a file or a SpreadsheetImageSource object to fit in the specified range.
Shape.InsertHyperlink Creates a new ShapeHyperlink object with the passed hyperlink destination. The hyperlink can refer to a web page, existing file or directory, e-mail address or cell range.
HyperlinkBase.TooltipText Specifies the hyperlink’s tooltip.This text is displayed when the cursor hovers over the picture.

The code sample below inserts a picture and attaches a hyperlink to it.

Spreadsheet_ShapeHyperlink

Picture picture = spreadsheetControl.Document.Worksheets[0].Pictures.AddPicture("DevExpress.png", spreadsheetControl.Document.Worksheets[0].Cells["A1"]);
ShapeHyperlink shapeHyperlink = picture.InsertHyperlink("https://community.devexpress.com/blogs/", true);
shapeHyperlink.TooltipText = "Check the recent DevExpress blogs";