Copy and paste are default behaviours for text boxes.What are you trying to
add?
On Monday, 6 August 2012 06:09:45 UTC+1, X wrote:
>
> Sup all!
>
> I'm very nubish at scripting in C# and am looking for a way to implement
> cut copy and paste on my windows application form.
>
> using System;
> using System.Collections.Generic;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Linq;
> using System.Text;
> using System.Windows.Forms;
> using System.IO;
>
> namespace MyWordPad3
> {
> public partial class WordPad : Form
> {
> //Short Variables
>
> private int docID = 0;
> private string strFileName = "";
> private DialogResult dlgResult;
> private StreamWriter sw;
> private bool modified = false;
>
> protected int docNumber = 0;
>
> /**/
>
>
> private void txtBody_TextChanged(object sender, System.EventArgs e)
> {
> modified = true;
> }
> public void Copy()
> {
> if (this.SelectedText != string.Empty)
> {
> Clipboard.SetText(this.SelectedText);
> }
> }
> private void CheckChanged(object sender, System.EventArgs e)
> {
> if (modified)
> {
> dlgResult = MessageBox.Show("Project not Saved.", "Note",
> MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
>
> if (dlgResult == DialogResult.Yes)
> {
>
> MenuItemMenuFileSave_Click(sender, e);
> }
> }
> }
>
>
> public WordPad()
> {
> InitializeComponent();
> }
>
> private void Form1_Load(object sender, EventArgs e)
> {
>
> }
>
> private void MenuItemMenuFileSave_Click(object sender, EventArgs e)
> {
>
> if(strFileName == "")
> {
> MenuItemMenuFileSave_Click(sender,e);
> return;
> }
> sw = new StreamWriter(strFileName);
> sw.Write (txtBody.Text);
> sw.Close();
> modified = false;
> }
>
> private void MenuItemMenuFileNew_Click(object sender, EventArgs e)
> {
> CheckChanged(sender, e);
> strFileName = "";
> txtBody.Clear();
>
> modified = false;
> }
>
> private void MenuItemMenuFileOpen_Click(object sender, EventArgs e)
> {
> CheckChanged(sender, e);
>
> dlgResult = openFileDialog1.ShowDialog();
> if (dlgResult == DialogResult.Cancel)
> return;
>
> try
> {
> strFileName = openFileDialog1.FileName;
> StreamReader sr = new StreamReader(strFileName);
> txtBody.Text = sr.ReadToEnd();
> sr.Close();
> modified = false;
> }
> catch (Exception err)
> {
> MessageBox.Show(err.Message, "Error",
> MessageBoxButtons.OK,
> MessageBoxIcon.Error);
> }
> }
>
> private void MenuItemMenuFileSaveAs_Click(object sender, EventArgs
> e)
> {
>
> saveFileDialog1.FileName = "mydoc" + docID.ToString() + ".txt";
> dlgResult = saveFileDialog1.ShowDialog();
>
> if (dlgResult == DialogResult.Cancel)
> return;
>
> try
> {
>
> strFileName = saveFileDialog1.FileName;
> sw = new StreamWriter(strFileName);
> sw.Write(txtBody.Text);
> sw.Close();
> MenuItemMenuFileSave.Enabled = true;
>
>
> docID++;
> modified = false;
> this.Text = "C# Simple Notepad: " + strFileName;
> }
> catch (Exception err)
> {
> MessageBox.Show(err.Message, "Error",
> MessageBoxButtons.OK,
> MessageBoxIcon.Error);
> }
> }
>
> private void MenuItemMenuEditCopy_Click(object sender, EventArgs e)
> {
>
> }
>
> }
> }
> I accept all suggestions and am appreciative of any help... Thanks.
>
> X
>
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net