Skip to main content
A newer version of this page is available. .

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();
      }
   }