复制:
private void button1_Click(object sender, System.EventArgs e) {
  // Takes the selected text from a text box and puts it on the clipboard.
  if(textBox1.SelectedText != ”")
  Clipboard.SetDataObject(textBox1.SelectedText);
  }

粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
 
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
}
主要通过调用Clipborad的API完成。

转自:http://www.cnblogs.com/michaelxu/archive/2008/11/04/1326184.html

C#复制、粘贴文本信息到剪贴板的更多相关文章

  1. 重新想象 Windows 8 Store Apps (40) - 剪切板: 复制/粘贴文本, html, 图片, 文件

    [源码下载] 重新想象 Windows 8 Store Apps (40) - 剪切板: 复制/粘贴文本, html, 图片, 文件 作者:webabcd 介绍重新想象 Windows 8 Store ...

  2. C# 复制、粘贴文本信息到系统剪贴板

    复制: Clipboard.SetDataObject(textBox1.SelectedText); 粘贴: IDataObject iData = Clipboard.GetDataObject( ...

  3. Mac复制粘贴文本时默认使用无格式模式

    参考:How to Paste Everything as Plain Text 写文章的时候,用的最多的就是copy和paste了,可是现在Mac和Win默认都是会连格式一起复制,真是逆天,导致每次 ...

  4. Javascript禁止网页复制粘贴效果,或者复制时自动添加来源信息

    一.禁止复制 使用方法:在oncopy事件中return false oncopy="return false;" 1.禁止复制网页内容 <body oncopy=" ...

  5. Android 复制 粘贴 剪贴板的使用 ClipboardManager

    Copy and Paste 版本:Android 4.0 r1  快速查看 用于复制粘贴数据的基于剪贴板的框架. 同时支持简单和复杂的数据,包括文本串.复杂的数据结构.文本和二进制流数据.程序 as ...

  6. Excel 如何复制粘贴一整行

    在某些时候,我们需要重复性的录入一些信息,而且表头都是一样的,一直拉列宽是相当令人烦躁的事情. 所以,就想可以直接复制黏贴出一整行,包括行的各个列宽. 具体操作如图: ——>首先,一整行复制, ...

  7. ios textfield / textview长按复制粘贴中文显示

    当我们在写应用时要复制粘贴文本框内容时,默认显示的文字为英文字体,可按如下步骤设置,显示中文:

  8. VB中复制-粘贴-剪切键实现

    If Me.ActiveControl.GetType.BaseType.ToString = "System.Windows.Forms.TextBoxBase" Then Wi ...

  9. Windwos服务器远程桌面不能复制粘贴的解决方法

    今天使用远程桌面连接登陆服务器,发现不能在本地电脑和远程服务器之间复制粘贴文件了,复制粘贴文本也不行. 网上搜了一下,主要有两种情况: 1.复制粘贴功能原本可以用,突然失灵了2.从头到尾都无法使用这个 ...

随机推荐

  1. 开关WIFI脚本

    title wifi管理color A@echo on@echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@echo 1.启用并设定虚拟WiFi网卡;@echo 2.开启无线网络; ...

  2. oracle asm 概念

    automated storage management ,即自动存储管理,简称asm .. 在oracle 10g 这个版本之前,管理一个大型数据库成千上万的数据文件对数据库管理员来说是一个既无技术 ...

  3. TortoiseGit 添加邮箱 失败保存配置

    解决方法   将保存至改为此版本库

  4. 升级centos内核到最新版本

    root权限执行: rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/ ...

  5. UIView的一些基本方法 init、loadView、viewDidLoad、viewDidUnload、dealloc

    init方法 在init方法中实例化必要的对象(遵从LazyLoad思想) ‍init方法中初始化ViewController本身 loadView方法 当view需要被展示而它却是nil时,view ...

  6. 【leetcode】Unique Binary Search Trees

    Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that st ...

  7. Django用户管理及认证

    同步组http://www.douban.com/group/topic/29387804/ ldapsearch -x -w password -D "cn=me,cn=Users,dc= ...

  8. MyBatis <if>标签的一些问题

    1.常见错误: There is no getter for property named 'parentId' in 'class java.lang.Long'(或者String) org.myb ...

  9. mysql中表名是order的CRUD的错误

    org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysql.jdbc. ...

  10. MySQL Plugin 'InnoDB' init function returned error

    . . 在MySQL的配置文件中,设定default-table-type=InnoDB,发现MySQL无法正常的启动,错误日志中给出了如下的信息: 150210 18:11:19 mysqld_sa ...