Techknow_Study

Notepad through VB 2010

Hey Programmer Friends! In this tutorial I am going to show you how to make an advanced  notepad in visual basic 2010 / 2008.
I will split this tutorial in to two (2) parts

PART 1  the design and behaviour of our application

And PART 2 the coding.

Let’s get started.

PART 1 –Design & Behaviour

Open VB and go to File>New Project>Windows Form Application> Call it whatever you like.

Ø  Now insert:

1 Menustrip
1 Text Box.
1 SavefileDialog

1 OpenfileDialog
1 FontDialog

make the form like These pictures


PART 2 – CODING

It’s the coding for different controls, and I think you understand that which code is for which controls. And for any other query leave a comment in comment box.

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_v
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private voidopenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //openFileDialog1.ShowDialog();
            if(openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
            {
            textBox1.Text=System.IO.File.ReadAllText(openFileDialog1.FileName);
            }
        }
        private voidsaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ///saveFileDialog1.ShowDialog();
            if(saveFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
            {
            System.IO.File.WriteAllText(saveFileDialog1.FileName,textBox1.Text);
            }
        }
        private voidsaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog1.ShowDialog();
        }
        private voidfontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fontDialog1.ShowDialog();
        }
        private voidnewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Text = “”;
        }
        private voidundoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Undo();
        }
        private voidcutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Cut();
        }
        private voidcopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Copy();
        }
        private voidpasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Paste();
        }
        private voidselectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.SelectAll();
        }
        private voidtoolStripMenuItem2_Click(object sender, EventArgs e)
        {
            textBox1.SelectedText = “”;
        }
        private voidfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }
      }
    }
I will update this code as I able to get code for other different tool.

Single Post Navigation

Leave a comment

Design a site like this with WordPress.com
Get started