Skip to main content

How to: Copy Selected Text in TextEdit Control

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

   private void button1_Click(object sender, System.EventArgs e) {
      if (textEdit1.SelectionLength > 0) { 
         textEdit1.Copy();
      }
   }