Skip to content

Commit 77fe9cc

Browse files
authored
Merge pull request #4 from SyncfusionExamples/KB-10098
KB-10098 - README.md
2 parents fd89e28 + f48ac57 commit 77fe9cc

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

GridHyperLinkColumn.png

89.5 KB
Loading

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1-
# how-to-modify-the-gridhyperlinkcolumn-text-in-winforms-datagrid
2-
How to modify the GridHyperLinkColumn text in WinForms DataGrid (SfDataGrid)?
1+
# How to modify the GridHyperLinkColumn text in WinForms DataGrid?
2+
3+
4+
By default In [WinForms DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid) (SfDataGrid), the text in [GridHyperLinkColumn](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.GridHyperlinkColumn.html) will be updated with provided link. To change the text of hyperlink in the cells, the DisplayText can be changed based on our requirement using [DrawCell](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.SfDataGrid.html#Syncfusion_WinForms_DataGrid_SfDataGrid_DrawCell) event.
5+
6+
```csharp
7+
//Event subscription
8+
this.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell;
9+
10+
//Event customization
11+
private void SfDataGrid1_DrawCell(object sender, DrawCellEventArgs e)
12+
{
13+
if(e.Column.MappingName == "Hyperlink")
14+
{
15+
string displayText = e.DisplayText;
16+
int index = displayText.LastIndexOf('.');
17+
int firstIndex = displayText.IndexOf('.');
18+
int length = displayText.Length - (displayText.Length - index) - firstIndex;
19+
displayText = e.DisplayText.Substring(firstIndex + 1, length - 1);
20+
21+
//To update text of hyperlink.
22+
e.DisplayText = displayText;
23+
}
24+
}
25+
```
26+
27+
![GridHyperLinkColumn](GridHyperLinkColumn.png)

0 commit comments

Comments
 (0)