Back to Devexpress

How to: Add a Hyperlink to a Picture

windowsforms-120746-controls-and-libraries-spreadsheet-examples-pictures-how-to-add-a-hyperlink-to-a-picture.md

latest1.9 KB
Original Source

How to: Add a Hyperlink to a Picture

  • Apr 22, 2022

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

MemberDescription
PictureCollection.AddPictureInserts a picture from a file or a SpreadsheetImageSource object to fit in the specified range.
Shape.InsertHyperlinkCreates 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.TooltipTextSpecifies 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.

csharp
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";
vb
Dim picture As Picture = spreadsheetControl.Document.Worksheets(0).Pictures.AddPicture("DevExpress.png", spreadsheetControl.Document.Worksheets(0).Cells("A1"))
Dim shapeHyperlink As ShapeHyperlink = picture.InsertHyperlink("https://community.devexpress.com/blogs/", True)
shapeHyperlink.TooltipText = "Check the recent DevExpress blogs"