Category / Section
How to create a cell that contains Hypertext link along with different format in WinForms GridControl?
1 min read
Hyperlink and text format applied in a grid cell
The RichText cell control in the library allows you to edit the text via a dropdown panel. By assigning the CellType as RichText, you can have a cell with the Hyperlink text and different formats.
C#
//Sets the CellType as RichText this.gridControl1[2, 2].CellType = GridCellTypeName.RichText; //The RTF text is having Bold, Italic and Hyperlink this.gridControl1[2, 2].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deftab709{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}" + @"{\colortbl ;\red0\green0\blue255;\red0\green0\blue128;}" + @"{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\lang1033\b\f0\fs24 Bold\b0\par" + @"\i Italic\i0\par" + @"{\field{\*\fldinst{HYPERLINK 'http://www.google.com/' }}{\fldrslt{\cf2\ul www.google.com}}}\cf0\ulnone\f0\fs24\par}";
VB
'Sets the CellType as RichText Me.gridControl1(2, 2).CellType = GridCellTypeName.RichText ' The RTF text is having Bold, Italic and Hyperlink Me.gridControl1(2, 2).Text = "{\rtf1\ansi\ansicpg1252\deff0\deftab709{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}" & "{\colortbl ;\red0\green0\blue255;\red0\green0\blue128;}" & "{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\lang1033\b\f0\fs24 Bold\b0\par" & "\i Italic\i0\par" & "{\field{\*\fldinst{HYPERLINK 'http://www.google.com/' }}{\fldrslt{\cf2\ul www.google.com}}}\cf0\ulnone\f0\fs24\par}"
The following screenshot displays the Cell that contains the Hyperlink and different formatted texts.
Samples: