Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
code for cut copy pAste in c# using menustrip edit menu
Posted
Comments
BillWoodruff 10-Nov-13 11:28am    
What have you tried so far ? We're not here to do homework.

C#
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;
        }
    }
}
 
Share this answer
 
Comments
winliya jewel 26-Dec-12 3:45am    
nice one.....
bt i have a doubt...for copy paste we need to setup a path file of data.txt???
Dineshshp 28-Dec-12 1:16am    
No it's just an example. you can load data in textbox from any where from you want...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900