Back to Devexpress

How to: Copy Selected Text in TextEdit Control

windowsforms-9522-controls-and-libraries-editors-and-simple-controls-examples-how-to-copy-selected-text-in-textedit-control.md

latest676 B
Original Source

How to: Copy Selected Text in TextEdit Control

  • Oct 25, 2019

The following sample code verifies whether any text is selected in a TextEdit control and, if so, copies the selected text onto the Clipboard.

csharp
private void button1_Click(object sender, System.EventArgs e) {
      if (textEdit1.SelectionLength > 0) { 
         textEdit1.Copy();
      }
   }
vb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
     Handles Button1.Click
      If TextEdit1.SelectionLength > 0 Then
         TextEdit1.Copy()
      End If
   End Sub