3000 TL ve üzeri siparişlerde Kargo Ücretsiz!
Developing a Simple Notepad Application with C#

Developing a Simple Notepad Application with C#

Step-by-step guide to building a simple Notepad app in C#: create project, add save and load functionality.

3 min read 1272 views

Developing a Simple Notepad Application with C#

Hello! In this article, we will learn step by step how to develop a simple Notepad application using the C# programming language. This application will allow users to create, edit, and save text-based notes.

Step 1: Creating the Project and Designing the User Interface

  1. First, create a C# project in an integrated development environment (IDE). I recommend using an IDE like Visual Studio. Create a new project named "NotDefteriUygulamasi".

  2. After creating the project, add a text box and a "Save" button to the main window of your project. These two components will allow users to enter text and enable you to save the entered text.

Step 2: Text Saving Functionality

  1. We will create the click function for the Save button. When the Save button is clicked, we will save the content from the text box to a file.

  2. Double-click the Save button to access the code section that will run when this button is clicked.

  3. Add the following code to the button's click handler:

    private void btnKaydet_Click(object sender, EventArgs e)
    {
        try
        {
            string notIcerik = txtNot.Text; // Metin kutusundaki içerik alınıyor.
            string dosyaYolu = "not.txt"; // Notların kaydedileceği dosyanın yolu belirleniyor.
    
            System.IO.File.WriteAllText(dosyaYolu, notIcerik); // İçerik dosyaya yazılıyor.
            MessageBox.Show("Not kaydedildi."); // Kullanıcıya bilgi veriliyor.
        }
        catch (Exception ex)
        {
            MessageBox.Show("Hata: " + ex.Message); // Hata durumunda kullanıcıya hata mesajı gösteriliyor.
        }
    }
    

Step 3: Text Loading Functionality

  1. Now, we need to ensure that the application loads previously saved notes when it starts.

  2. To call this function when the form loads, follow these steps. Return to the form design and open the properties window to view the events of the main window. Find the "Load" event and double-click it to go to the code editor.

  3. Add the following code inside this event:

private void YukleNot()
{
    string dosyaYolu = "not.txt"; // Okunacak dosyanın yolu belirleniyor.

    if (System.IO.File.Exists(dosyaYolu))
    {
        string notIcerik = System.IO.File.ReadAllText(dosyaYolu); // Dosya içeriği okunuyor.
        txtNot.Text = notIcerik; // Metin kutusuna içerik yazdırılıyor.
    }
}

private void MainForm_Load(object sender, EventArgs e)
{
    YukleNot(); // Form yüklendiğinde notları yükleme işlevi çağrılıyor.
}

Step 4: Running the Application

When you reach this step, you will have completed a simple Notepad application. When you start your application, you will be able to save and load notes written in the text box.

This application can be a great example to understand and use the basic features of the C# programming language. In the future, you can design more advanced applications by using these basic structures when developing more complex projects.

Share
Back to all posts

Yorumlar

No comments yet. Be the first to write one.

Your email is not published. Comments are reviewed before publishing.

This form is protected by Google reCAPTCHA; the Google Privacy Policy and Terms of Service apply.

Benzer Yazılar

What is C#? What Does It Do?

What is C#, what is it used for, and where is it used? Learn about Microsoft's object-oriented language C# and its applications in desktop,…

Read More

C# File Renaming Application

Learn step by step how to develop a Windows Forms-based bulk file renaming application with C#. Simplify your file management tasks.

Read More

Developing a Todo List Application with C#

In this guide, you will learn step by step how to develop a to-do list application using C#, including how to use text boxes and buttons. Yo…

Read More
Hızlı Kargo Hafta içi saat 15:00 öncesinde oluşturduğunuz tüm siparişler aynı gün kargoya verilmektedir.
Güvenli Alışveriş Tüm bilgileriniz 256 Bit SSL sertifikasıyla korunmaktadır.
Uzman Teknik Servis Ürünleriniz için profesyonel bakım ve onarım.
Ücretsiz Kargo Belirli tutarın üzerindeki alışverişlerinizde kargo ücreti ödemezsiniz.

Bültenimize Abone Ol

Kampanya ve fırsatlardan ilk siz haberdar olun.

Kuruköprü Mah. Sefa Özler Cad. özden İşmerkezi kat 7/74 Seyhan / adana

Ödeme Yöntemleri

Visa Mastercard Banka Kartı World

©2017 - 2026 All rights reserved.