Create notepad using C# and windows form Part 1

notepad by Inder

Create a notepad using C# and windows form

Introduction

In this article I am going to describe some common control available in the C# and using these controls we design our own Notepad in C# with some advance feature like launch the html page directly in the browser by just one click, send email from the notepad via outlook or other email service installed in your computer and search selected text in google and Wikipedia etc. .

Some common controls used in mynotepad development are given bellow:

    1. Rich Textbox :Rich Textbox is an advanced textbox control with very interactive features and large number of properties. It supports the RTF (Rich Text Format) format. Rich textbox have some advance properties and it is in multiline mode by default . To use the Rich Textbox in the project the assembly required to refer is PresentationFramework (in PresentationFramework.dll) and the namespace is System.Windows.Control . Bellow I am going to describe some of its properties that we use in our project:
      • Context menu strip: By this property we can get or set the context menu element that should appear whenever the context menu is requested by the user. Context Menu strip is explained letter.
      • Cursor: Get and set the cursor that displays when the mouse pointer is over this element. In this project we set its value as IBeam . Other than IBeam there are many options like arrow, cross, default etc. .
      • Dock: This property define automatically resize the control when the size of the parent container is changed. For our project we the value of this property as fill.
      • Tooltip: Get or set the tool tip object that is displayed for this element in the user interface (UI).

      These are some properties that we handle when in our project. There are many other properties of Rich Textbox that we explain when we need it.

richtexbox property

  1. Menu Strip: The next control is menu strip that we use in our project. The menu strip adds the menu bar in Windows form ,we add menu area and then add default menus and create custom menus directly in visual studio. The assembly required for this control is System.Windows.Form(in System.Windows.Form.dll) an namespace is System.Windows.Form . We can add menu strip directly by drag and drop or at run time.
    Picture given bellow shows how the item is added in the Menu Strip.

menu strip1

 

You can also add the items in menu strip by the wizard as shown bellow:

menustrip

 

Note: Use & before the menu key to use hot keys. For example type &File in place of file in menu item. Than we can access this by pressing CTRL+F key on key board .

  • Tool strip: The next control is tool strip that we use in our project. Tool Strip provide container for windows toolbar object.
    The use of this can be shown as :

toolstrip1You can see the items that can be added in the ToolStrip are button , label , split button etc.

Now after adding any item you can adjust its properties according to need by right click on that item as shown bellow:toolstrip2

 

  • Status Strip : The next control used is status strip. It is used to show some quick help and control to the user (at the bottom of notepad shows line number and column number). The C# status strip allow you to add label , progress bar and button also.

status strip

Now all the basic tool required to design the layout of the notepad have been covered. Bellow the steps to develop own customized notepad is given

    1. Open Visual Studio and create a new project by giving it an appropriate name.
    2. Now change the following properties of the Form1 that is default form.
      • Give it a name.
      • Set backcolor as control .
      • Add appropriate icon by giving the path for icon property and set its size .
      • Set the windowstate property as maximize so whenever the form runs it covers the complete screen.
      • Set the text of form as Untitled Untitled-My Notepad, that we change at run time.

Now the the parent container is ready .

Drag and drop the Rich Textbox from the toolbox in the form and from properties window change its properties as

      • Set only the dock property as fill so the size of Rich Textbox is changed according with size of the form.

Now Form look like as

look1

 

  1. Now drag and drop the MenuStrip control from the control window and add the required menu items and their icons.
  2. Now add ToolStrip control from the toolbox and insert the required items with icons in it.

After the addition of the above control our form looks like as :

look2

look3Now we have the layout of our note pad but the functioning of any feature is not define.

In the next few articles I will explain the code for each functionality and also attach the program code with the article

Please give your valueable suggestion and feedback.

  1. Seriously, great blog page layout! How long have you ever been blogs intended for? you are making blogging glance easy. The overall search of NHSEO Free your respective web-site is fantastic, let alone the information material!

  2. Sir,
    Thank you for this wonderful application.But when I try to execute the code for NEW option It says that fname and save does n’t exists in this context.I am a very beginner in this language and I need help ……………….please reply soon……………

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge