c#中剪切复制粘贴的代码 [英] code for cut copy paste in c#
本文介绍了c#中剪切复制粘贴的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用menustrip编辑菜单在c#中剪切复制pAste的代码
解决方案
http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/CutCopyPasteTextBoxwithToolbar.htm [ ^ ]
使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Text;
使用 System.Windows.Forms;
命名空间 WindowsApplication1
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click( object sender,EventArgs e)
{
}
private void exitToolStripMenuItem_Click( object sender,EventArgs e)
{
此跨度> .Dispose();
}
private void copyToolStripMenuItem_Click( object sender,EventArgs e)
{
Clipboard.SetText(txt.SelectedText);
}
private void cutToolStripMenuItem_Click( object sender,EventArgs e)
{
Clipboard.SetText(txt.SelectedText);
txt.SelectedText = string .Empty;
}
private void pasteToolStripMenuItem_Click( object sender,EventArgs e)
{
string xx = Clipboard.GetText();
txt.Text = txt.Text.Insert(txt.SelectionStart,xx);
}
private void Form1_Load( object sender,EventArgs e)
{
txt.Text = System.IO.File.ReadAllText( @ C:\ Data.txt);
}
private void wordWrapToolStripMenuItem_Click( object sender,EventArgs e)
{
txt.WordWrap =!txt.WordWrap;
}
}
}
code for cut copy pAste in c# using menustrip edit menu
解决方案
http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/CutCopyPasteTextBoxwithToolbar.htm[^]
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void newToolStripMenuItem_Click(object sender, EventArgs e) { } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { this.Dispose(); } private void copyToolStripMenuItem_Click(object sender, EventArgs e) { Clipboard.SetText(txt.SelectedText); } private void cutToolStripMenuItem_Click(object sender, EventArgs e) { Clipboard.SetText(txt.SelectedText); txt.SelectedText = string.Empty; } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { string xx = Clipboard.GetText(); txt.Text = txt.Text.Insert(txt.SelectionStart, xx); } private void Form1_Load(object sender, EventArgs e) { txt.Text = System.IO.File.ReadAllText(@"C:\Data.txt"); } private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e) { txt.WordWrap = !txt.WordWrap; } } }
这篇关于c#中剪切复制粘贴的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文