Working with Stream Reader and Stream Writer class:-
- Stream Reader is used to read the data from a file.
- Stream Writer is used to write the data information in to file.
Methods of Stream Reader and Stream Writer classes:-
String S = “String /n ;
String /n………..” Write (“abc”);
Write (“xyz”);
Abc xyz
What is DOCK?
- This is a property, which is available for all visible controls.
- Dock property resizes a control Relatively with form Size.
What is the Anchor?
- Anchor property repositions a control relatively with form size
- Developing An application like a notepad
- Options required in note pad
File Edit Format Help
New Select All Fonts Help topics
Open Cut Colors About
Save Copy
Print Paste
Exit
The following controls are required to develop a notepad
- Text Box
- Menu Strip
- Open File Dialog
- Save File Dialog
- Print Dialog
- Color Dialog
- Font Dialog
Interested in mastering .NET? Learn more about ".NET Training" in this blog post.
- Open windows Forms Application Project name my note
- Place all above 7 controls on the form
- Choose text box
properties
Multiline = true
Dock = fill
Scrollbars = both
Allow drop = true
- Select Menu strip control and design it with the above-discussed options
- Assigning an Icon to a menu item
Right click on new set Image
choose an image
- Assigning a short – cut key
Right click on cut properties
short cut key
- Select a combination
{Using System . Io;
Using System . Drawing .Printing
}
Code for new menu Item (double click on new)
{
Text Box1. Text = “”;
}
Code for open menu Item
{
Open File Dialog 1. Show Dialog ();
String p = Open File Dialog 1. File Name;
Message box. Show (p);
Stream Reader sr = new Stream Reader (p);
Text box 1 .text = sr. Read To end ();
Sr. close ();
}
Code for save menu item
{
Save File Dialog 1. Show Dialog ();
String p = Save File Dialog 1 .File Name;
Stream Writer sw = new Stream Writer (p);
Sw. Write (text box1. text);
Sw. Flush ();
Sw. Close ();
}
Code for Print
{
Printer Setting ps = new Printer Settings ();
Print Dialog 1 .Printer Strings = ps;
Print Dialog1. Show Dialog ();
}
Code for exit {
Application .Exit ();
}
Code for Select ALL
{
Text box1.Select ALL();
}
Code for cut
text box 1.cut ();
- Code for copy
text box1.copy ();
- Code for paste
textbox1.paste ();
- Code for Fonts
Font Dialog1.Show Dialog (); Text box 1. Font = font Dialog1. Font;
- Code for colors
{ Color Dialog1. Show Dialog (); Text Box 1.fore color Dialog1. Color; }
- Code for Help Topics
{Label L =new label ();
Dock = Dock Style .Fill ;
Font = new Font (“Arial”, 20)
Text = “ Type Help messages here” ;
Form f = new Form ();
control S .Add (L);
Show Dialog ();
}
View menu Solution Explorer
right-click on my note (project name)
add à new item
About box and provide the name test
Code for About{
Test t = new Test ();
Show ();
}