Breaking News

Bluetooth 5 Will Be

Late last year we got an early look at  improvements  coming to the next version of Bluetooth, and now the Bluetooth Special Interest ...

Monday, April 25, 2016

How to make simple text editor in C#

by Unknown  |  in C# Tutorial at  4:27:00 AM


1.       Build your form

You need textbox, two Buttons, Savefiledialog and OpenFile Dialog  .
And make the text box MULTI LINE 


Add a string variable “name” (this must be public)
public partial class Form1 : Form
    {
        string name;
        public Form1()
        {
            InitializeComponent();
        }
Add a namespace System.IO;
using System.IO;

1.       Write tis code for Open button

Add a string variable “name” that means the file name.

string name;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                name = openFileDialog1.FileName;
                textBox1.Clear();
                textBox1.Text = File.ReadAllText(name);
            }



2.       Now write this code for SAVE button

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                name = saveFileDialog1.FileName;
                File.WriteAllText(name, textBox1.Text);
            }


3.       Now you are done. 




0 comments:

Proudly Powered by Blogger.