Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a Hyperlink Cell |
You can use a hyperlink cell to contain text that functions as a single hyperlink or multiple hyperlinks. The destination of the hyperlink can be any universal resource locator (URL). For example:
You can specify how much of the text functions as a hyperlink and the rest displays as ordinary text. You can specify the appearance of the hyperlinked text and customize the color of the link that has been followed (visited or clicked).
Property | Customization |
---|---|
BackgroundImage | Sets the background graphic image. |
Link | Sets the destination URL. |
LinkArea | Sets the area of the text that is the hyperlink. |
LinkAreas | Sets the area of the text that is the hyperlink. |
LinkColor | Sets the color of links (before they are followed). |
Links | Sets the hyperlinks. |
Text | Sets the label of the hyperlink, that is, what appears in the cell. |
VisitedLinkColor | Sets the color of followed links. |
To create a cell that acts like a hyperlink, use the HyperLinkCellType class. Create a hyperlink cell using the following procedure. The results of the procedure, both normal and followed links, are shown in the following figure.
Hyperlink Text Before Clicking Link | Hyperlink Text After Following Link |
---|---|
The following figure displays a hyperlink cell with multiple links.
For more information on the properties and methods of this cell type, refer to the HyperLinkCellType class.
For more information on the corresponding event when a user clicks on a hyperlink, refer to the FpSpread.ButtonClicked event.
This example sets the size of the cell (by column and row), creates a hyperlink button, and specifies the destination URL.
C# |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.Columns[1].Width = 145; fpSpread1.ActiveSheet.Rows[1].Height = 45; FarPoint.Win.Spread.CellType.HyperLinkCellType hlnkcell = new FarPoint.Win.Spread.CellType.HyperLinkCellType(); hlnkcell.Text = "Click to See Our Web Site"; hlnkcell.Link ="http://www.componentone.com"; hlnkcell.LinkArea = new LinkArea(9,16); hlnkcell.LinkColor = Color.DarkGreen; hlnkcell.VisitedLinkColor = Color.Chartreuse; fpSpread1.ActiveSheet.Cells[1, 1].CellType = hlnkcell; |
VB |
Copy Code
|
---|---|
FpSpread1.ActiveSheet.Columns(1).Width = 145 FpSpread1.ActiveSheet.Rows(1).Height = 45 Dim hlnkcell As New FarPoint.Win.Spread.CellType.HyperLinkCellType() hlnkcell.Text = "Click to See Our Web Site" hlnkcell.Link ="http://www.componentone.com" hlnkcell.LinkArea = new LinkArea(9,16) hlnkcell.LinkColor = Color.DarkGreen hlnkcell.VisitedLinkColor = Color.Chartreuse FpSpread1.ActiveSheet.Cells(1, 1).CellType = hlnkcell |
This example creates a hyperlink cell with multiple links.
C# |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.Columns[0].Width = 145; fpSpread1.ActiveSheet.Rows[0].Height = 45; FarPoint.Win.Spread.CellType.HyperLinkCellType mhp = new FarPoint.Win.Spread.CellType.HyperLinkCellType(); mhp.Text = "FarPoint and Microsoft"; string[] s = new string[]{"www.fpoint.com", "www.microsoft.com"}; mhp.Links = s; mhp.VisitedLinkColor = Color.Maroon; LinkArea[] la = new LinkArea[]{new LinkArea(0, 8), new LinkArea(13, 9)}; mhp.LinkAreas = la; fpSpread1.ActiveSheet.Cells[0, 0].CellType = mhp; |
VB |
Copy Code
|
---|---|
FpSpread1.ActiveSheet.Columns(0).Width = 145 FpSpread1.ActiveSheet.Rows(0).Height = 45 Dim mhp As New FarPoint.Win.Spread.CellType.HyperLinkCellType mhp.Text = "FarPoint and Microsoft" Dim s() As String = New String() {"www.fpoint.com", "www.microsoft.com"} mhp.Links = s mhp.VisitedLinkColor = Color.Maroon Dim la() As LinkArea = New LinkArea() {New LinkArea(0, 8), New LinkArea(13, 9)} mhp.LinkAreas = la FpSpread1.ActiveSheet.Cells(0, 0).CellType = mhp |
Or right-click on the cell or cells and select Cell Type. From the list, select HyperLink. In the CellType editor, set the properties you need. Click Apply. If you create multiple hyper links then make sure the text is set as well. Note that if you were to create the previous code sample in the designer then the text would need to contain 23 characters since the second link starts at 13 and continues for 9 characters. The text is zero based.