Progressbar - Timer 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;
using System.Collections;
namespace ProgressBar___Timer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        ArrayList sayi = new ArrayList();
        int k = 20;
        private void button1_Click(object sender, EventArgs e)
        {
            k = 20;
            progressBar1.Value = 0;
            label1.Visible = true;
            label1.Text = k.ToString();
            timer1.Start();
            while (k != 0)
            {
                string a = Microsoft.VisualBasic.Interaction.InputBox("Sayı giriniz...", "SAYI GİRİŞİ", "", 500, 500).ToString();
                if (a != "")
                {
                    int n = Convert.ToInt32(a);
                    sayi.Add(n);
                }
            }        
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
           
            progressBar1.Value += 1;
            k -= 1;
            label1.Text = k.ToString();

            if (k % 2 == 1)
            {
                label1.ForeColor = Color.Firebrick;
            }
            else
            {
                label1.ForeColor = Color.Blue;
            }

            if (k == 0)
            {
                timer1.Stop();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            int m = 0;
            int c = sayi.Count;

            for (int i = 0; i < c; i++)
            {
                listBox1.Items.Add(++m + ")  " + sayi[i]);
            }
        }
    }
}




-----------------------------------------------------------------------------------------------------------------


Formun tamamı için Tıklayınız.



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;
using System.Collections;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        ArrayList okul = new ArrayList();
        ArrayList ad = new ArrayList();
        int m = 33;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                string a = MessageBox.Show("Boş olan var kaydetmek istermisin ?", "Doğrulama", MessageBoxButtons.YesNo).ToString();
                if (a == "Yes")
                {
                    okul.Add(textBox1.Text);
                    ad.Add(textBox2.Text);
                }
                else
                {
                    textBox1.Focus();
                }
            }
            else if (textBox2.Text == "")
            {
                string a = MessageBox.Show("Boş olan var kaydetmek istermisin ?", "Doğrulama", MessageBoxButtons.YesNo).ToString();
                if (a == "Yes")
                {
                    okul.Add(textBox1.Text);
                    ad.Add(textBox2.Text);
                }
                else
                {
                    textBox2.Focus();
                }              
            }
            else
            {
                okul.Add(textBox1.Text);
                ad.Add(textBox2.Text);
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            m = m - 1;
            label1.Text = m.ToString();
            if (progressBar1.Value < 34)
            {
                int b = progressBar1.Value += 1;
                label1.Text = b.ToString();
            }
            if (m == 1)
            {          
                timer1.Stop();
                panel1.Visible = false;
                label1.Text = "Süre bitti";
            }         
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int n=0;
            for (int k = 0; k <ad.Count; k++)
            {
                listBox1.Items.Add(++n + ")" + okul[k] + " " + ad[k]);
            }
        }
    }
}

1 yorum:

  1. if (progressBar1.Value < 34)
    {
    int s=progressBar1.Value += 1;
    label1.Text = s.ToString();
    }
    kısa yolu

    YanıtlaSil