C# ProgressBar Nesnesi Örneği - Bilişim Konuları

C# ProgressBar Nesnesi Örneği

Bu örneğimizde c# progressbar nesnesi kullanımı ile ilgili bir örnek program yapacağız. Örneğimizde ekrana bir tane progressbar nesnesi bir tane button nesnesi bir tane timer nesnesi bir tanede label nesnesi ekliyoruz. Progressbar nesnesini timer nesnesinin tick olayına bağlıyoruz. Timer nesnesinin her değişmesinde progressbar nesnesini biraz daha dolduruyoruz. Bu örnek bilgisayarımıza bir program kuruyormuşuz gibi programın yüklenmesini temsil ediyor. Yükleme işlemi yarıda iken sanki yükleme hatası veriyormuş gibi hata nesajı veriyor ve progressbar nesnesinin yüklemesi durduruluyor. Hepsi bu kadar.

Programın C# görüntüleri:

prograsbar-nesnesi1

prograsbar-nesnesi1

prograsbar-nesnesi2

prograsbar-nesnesi2

Programın C# kodları:

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

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

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
            timer1.Interval = 200;
        }

        private void timer1_Tick(object sender, EventArgs e)
        { 
            progressBar1.Increment(1);

            label1.Text = "%"+progressBar1.Value.ToString();
            if (progressBar1.Value == 50) { timer1.Stop(); 
            MessageBox.Show("hata oluştu");
            }
        }
    }
}
Bu Yazıya Tepkin Nedir?
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Sonraki Yazı >>

Yorum Yap