Text Selection in Windows Forms Html Viewer (HTMLUI)

28 Apr 2021 / 1 minute to read

An interesting feature of the HTMLUI control is its ability to access the selected text. This feature helps the user to select required texts available in the HTMLUI control and use the selected text in the applications. The SelectedText property of the HTMLUI control is used for this purpose.

// Return the selected text displayed in  the control

this.label1.Text = this.htmluiControl1.SelectedText;
' Return the selected text displayed in the control

Me.label1.Text = Me.HtmluiControl1.SelectedText


The HTMLUI control allows the user to copy the text selected in the HTMLUI control to the Clipboard, and paste it in other applications. The following code snippet shows how this feature is implemented with the HTMLUI control.

string text = this.htmluiControl.SelectedText.ToString();

if (text != "")


//Copying the selected text to the ClipBoard


Private text As String = Me.htmluiControl.SelectedText.ToString()

If text <> "" Then

' Copying the selected text to the ClipBoard


End If

HTMLUITextSelection sample

This sample demonstrates the support for Text Selection in HTMLUI.

HTMLUIControl supports text selection

By default, this sample can be found under the following location:

…_My Documents\Syncfusion\EssentialStudio\Version Number\Windows\HTMLUI.Windows\Samples\Advanced Editor Functions\ActionGroupingDemo_