29 Haziran 2015 Pazartesi

C# Not Defteri Yapımı

Evet arkadaşlar bu gün textbox kontrolü ile basit bir not defteri yapmayı öğreneceğiz.
Programımız çok kapsamlı olmayıp, daha sonra istenirse geliştirilebilir.



 Programımızın ekran görüntüsü aşağıdaki gibi olacak...




Evet arkadaşlar programımızın kodlarını yazmaya başlamadan önce textbox kontrolümüzün MaxLength property sini 500 olarak ayarlıyoruz.
Uygulama kodlarımız aşağıdaki gibi olacak..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace textBoxEditor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Kes_Click(object sender, EventArgs e)
        {
            if (textBox1.SelectionLength>0)
            {
                textBox1.Cut();
            }
            else
            {
                MessageBox.Show("Seçili Alan Yok");
            }
        }

        private void btn_Kopyala_Click(object sender, EventArgs e)
        {
            if (textBox1.SelectionLength>0)
            {
                textBox1.Copy();
            }
            else
            {
                MessageBox.Show("Seçili Alan Yok");
            }
        }

        private void btn_Yapistir_Click(object sender, EventArgs e)
        {
            textBox1.Paste();
        }

        private void btn_GeriAl_Click(object sender, EventArgs e)
        {
            textBox1.Undo();
        }

        private void btn_YaziTipi_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog()==DialogResult.OK)
            {
                textBox1.Font = fontDialog1.Font;
            }
        }

        private void btn_YaziRengi_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog()==DialogResult.OK)
            {
                textBox1.ForeColor = colorDialog1.Color;
            }
        }

        private void btnKalin_Click(object sender, EventArgs e)
        {
            textBox1.Font = new Font(Font, FontStyle.Bold);
        }

        private void btn_Egik_Click(object sender, EventArgs e)
        {
            textBox1.Font = new Font(Font, FontStyle.Italic);
        }

        private void btn_AltiCizgili_Click(object sender, EventArgs e)
        {
            textBox1.Font = new Font(Font,FontStyle.Underline);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            int karaktersayisi = 500 - textBox1.Text.Length;
            this.Text = "Kalan Karakter Sayısı : " + karaktersayisi.ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.MaxLength = 500;
            this.Text = "Kalan Karakter Sayısı : 500";
        }
    }
}

Hiç yorum yok: