Skip to content

SyncfusionExamples/how-to-modify-the-gridhyperlinkcolumn-text-in-winforms-datagrid

Repository files navigation

How to Modify the GridHyperLinkColumn Text in WinForms DataGrid?

This sample illustrates about how to modify the GridHyperLinkColummn text in WinForms DataGrid (SfDataGrid).

By default In DataGrid, the text in GridHyperLinkColumn 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 event.

//Event subscription
this.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell;
 
//Event customization
private void SfDataGrid1_DrawCell(object sender, DrawCellEventArgs e)
{
    if(e.Column.MappingName == "Hyperlink")
    {
        string displayText = e.DisplayText;
        int index = displayText.LastIndexOf('.');
        int firstIndex = displayText.IndexOf('.');
        int length = displayText.Length - (displayText.Length - index) - firstIndex;
        displayText = e.DisplayText.Substring(firstIndex + 1, length - 1);
 
        //To update text of hyperlink.
        e.DisplayText = displayText;
    }
}

DataGrid with Modified GridHyperLinkColumn text

About

How to modify the GridHyperLinkColumn text in WinForms DataGrid (SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages