Monday, 19 September 2016

Creating Notepad using C#.net

Tags


Write A code in c# for creating a notepad that should have the  functionality  like New,Copy,Save,Paste,Delete etc.


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;

namespace Notepad
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "";
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            //richTextBox1.Text = "";
        }
//code block for open file dialog to open new file .
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            openFileDialog1.Filter = "All Files(*.*)|*.*|Rich text Format(*.rtf)|*.rtf|Text Document(*.txt)|*.txt";
            richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);

        }
//code block for Undo Operation.
        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Undo();
        }
//code block for  Redo Operation.
        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Redo();
        }

//code block for  Copy Operation.
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }

//code block for  Paste Operation.
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Paste();

        }

//code block forT0 Select All Data Operation.
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.SelectAll();
        }

//code block for  Cut Operation.
        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Cut();
        }

//code block for  Clear  Operation.
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();

        }

//code block for change the font of data.i.e. to show font dialog box.
        private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fontDialog1.ShowDialog();
            richTextBox1.SelectionFont = fontDialog1.Font;
        }
//code block for change the color of data.i.e. to show color dialog box.
        private void colorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            richTextBox1.SelectionColor = colorDialog1.Color;
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.SaveFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
        }
//code block for open file dialog to save new file .
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog savedlg = new SaveFileDialog();
            savedlg.Filter = "All Files(*.*)|*.*|Rich text Format(*.rtf)|*.rtf|Text Document(*.txt)|*.txt";
            DialogResult res = savedlg.ShowDialog();
            if (res == DialogResult.OK)
            {
                richTextBox1.SaveFile(savedlg.FileName,RichTextBoxStreamType.PlainText);
            }
        }
//code block for  Exit the Application .
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();

        }
//code block for  Copy through toolbar Symbol  Operation.
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }
//code block forcreate new file  through toolbar Symbol  Operation.
        private void toolStripButton3_Click(object sender, EventArgs e)
        {

            richTextBox1.SaveFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            fontDialog1.ShowDialog();
            richTextBox1.SelectionFont = fontDialog1.Font;
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            richTextBox1.SelectionColor = colorDialog1.Color;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            richTextBox1.Paste();
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            richTextBox1.Redo();
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            richTextBox1.Undo();
        }

        private void toolStripButton9_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            openFileDialog1.Filter = "All Files(*.*)|*.*|Rich text Format(*.rtf)|*.rtf|Text Document(*.txt)|*.txt";
            richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
        }
    }
}
Read: How to Download Muzhiwan apk for android and ios.
##########################################################################
And Here is The Output:




EmoticonEmoticon