日期:2014-05-18  浏览次数:21150 次

c#实现剪切/复制/粘贴/全选操作
请问用c#怎样实现剪切/复制/粘贴/全选操作?

------解决方案--------------------
// 复制
System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
s.Add(@ "D:\WOW ");
Clipboard.SetFileDropList(s);

// 粘贴
if (Clipboard.ContainsFileDropList())
{
Clipboard.SetFileDropList(s);
//操作 s
}

// 剪切为先复制,粘贴后删除
------解决方案--------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
using System.Data;

namespace 记事本
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class FormMain : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBoxEdit;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemEdit;
private System.Windows.Forms.MenuItem menuItemFormat;
private System.Windows.Forms.MenuItem menuItemNew;
private System.Windows.Forms.MenuItem menuItemOpen;
private System.Windows.Forms.MenuItem menuItemSave;
private System.Windows.Forms.MenuItem menuItemSaveAs;
private System.Windows.Forms.MenuItem menuItemPageSet;
private System.Windows.Forms.MenuItem menuItemPrint;
private System.Windows.Forms.MenuItem menuItemExit;
private System.Windows.Forms.MenuItem menuItemUndo;
private System.Windows.Forms.MenuItem menuItemCut;
private System.Windows.Forms.MenuItem menuItemCopy;
private System.Windows.Forms.MenuItem menuItemPaste;
private System.Windows.Forms.MenuItem menuItemDel;
private System.Windows.Forms.MenuItem menuItemSelAll;
private System.Windows.Forms.MenuItem menuItemWordWrap;
private System.Windows.Forms.MenuItem menuItemFont;
private System.Windows.Forms.MenuItem menuItemColor;
const int MaxLenght=2000000;

private string currentFileName;
private System.Drawing.Printing.PrintDocument printDocument=new PrintDocument();
private bool needToSave;
public FormMain()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


------解决方案--------------------
代码太多,贴不完了,你要就加我Q8167452
------解决方案--------------------
还是Clipboard


粘帖:

IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text) | iData.GetDataPresent(DataFormats.OemTe