Copy or Paste Text to Clipboard in C#


Sajjad Arif Gul - April 20, 2016 - 3 comments

This C# tutorial is explaining about how to Paste text or data from Clipboard & How to copy text or data to Clipboard. You can also check the active data or text on clipboard in this Csharp example program. Here is the source code with explanation of it.

Copying Text to Clipboard in C#

First we will discuss about Copying to clipboard. This example simply builds an array of string names and places it in the clipboard, setting its data type to FileDrop in the Event. Below is a sample code of it.

As you can check the comments of above code. It first populate a List with Files Name from any directory which you can set as your need. Then it Clear the already copied data from clipboard & then it Copies this List to Clipboard.

Pasting Text from Clipboard in C#

Now we are discussing this below example of How to Paste Data or Text from Clipboard to your selected Control. Lets have a look at its source code.

In above code we simply creates an array of string which we filled from array of Text or data of Clipboard by using FileDrop method. In next step we just populate our selected control from the string array. In my case I populate a listbox here.

Author avatar

Sajjad Arif Gul

http://sajjadgul.com
Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts

3 comments

  1. Anonymous

    its simple & clear. thanks for the post. keep up these csharp good work.

  2. Anonymous

    how did it just work ?? i was looking for it everywhere.

  3. I see your site is similar to my page. Do you allow guest posting?
    I can write high quality & unique content for you.
    Let me know if you are interested.

Post a Comment

Your email address will not be published. Required fields are marked *