C# HAREKET EDEN BUTTON

C# ile hareket eden ve tıklayınca duran button uygulaması.


Formun üzerine 2 button ve 1 timer sürükleyip bırakın timer üzerine çift tıklayarak timer tick_eventine aşağıdaki kodları yazın.

      int Tm = 0;
        int Y1 = 10;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if(Tm==0)
            {
                Y1 += 10;
                button2.Top += 10;
                if(Y1>400)
                {
                    Tm = 1;
                }
            }
            if(Tm==1)
            {
                Y1 -= 10;
                button2.Top -= 10;
                if(Y1<10)
                {
                    Tm = 0;
                }
            }
        }
    }


Button1 üzerine çift tıklayarak oluşan click eventine aşağıdaki kodları yazın.

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

Button2 üzerine çift tıklayarak oluşan click eventine aşağıdaki kodları yazın.

      private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
        }

Form üzerine çift tıklayarak oluşan form_load eventine aşağıdaki kodları yazabilirsiniz.

      private void Form1_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }


Kolay Gelsin



SANATSAL BİLGİ

25/08/2016

  • YORUM YAZ
  • ADI SOYADI(veya nick)
  • YORUM

COPYRIGHT© HER HAKKI SAKLIDIR
Sitede Yer Alan Bilgi Belge Ve Materyallerin İzinsiz olarak Kopyalanması ve Alıntılanması Yasaktır

SANATSAL BILGI