.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

NotePad like application in C#

Posted By:Nikhil Kumar       Posted Date: January 12, 2010    Points: 25    Category: C#    URL: http://www.dotnetspark.com  

Notepad 2009 is very much interactive then default notepad developed in C#.NET with tool buttons Download and enjoy working
 

The UI of Notepad 2009 looks like following:

NOTEPAD 2009 ____

 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (r.Modified == true)
            {
                System.Windows.Forms.DialogResult answer;
                answer = MessageBox.Show("Save this document before closing?", "Unsaved Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (answer == System.Windows.Forms.DialogResult.Yes)
                {
                    if (currentFile == string.Empty)
                    {
                        saveAsToolStripMenuItem_Click(this, e);
                        return;
                    }


                    {
                        string strExt;
                        strExt = System.IO.Path.GetExtension(currentFile);
                        strExt = strExt.ToUpper();
                        if (strExt == ".RTF")
                        {
                            r.SaveFile(currentFile);
                        }
                        else
                        {
                            System.IO.StreamWriter txtWriter;
                            txtWriter = new System.IO.StreamWriter(currentFile);
                            txtWriter.Write(r.Text);
                            txtWriter.Close();
                            txtWriter = null;
                            r.SelectionStart = 0;
                            r.SelectionLength = 0;
                        }

                        this.Text = "NotePad 2009: " + currentFile.ToString();
                        r.Modified = false;

                    }
                }
                else
                {
                    r.Modified = false;
                    Application.Exit();
                }
            }
            else
            {
                r.Modified = false;
                Application.Exit();
            }
        }
           
 private void savedata()//create this function
        {
            if (filename == "")
            {
                saveFileDialog1.Filter = "Text Files|*.txt|HTML Files|*.htm|All Files|*.*";
                DialogResult res = saveFileDialog1.ShowDialog();
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                filename = saveFileDialog1.FileName;
                MessageBox.Show(filename);
            }
            StreamWriter sw = new StreamWriter(filename);
            sw.WriteLine(r.Text);
            sw.Flush();
            sw.Close();
        }

 

Download the attached project and open in Visual Studio

2005 to learn more about this application.

 

Thanks !

Nikhil Kumar

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend