• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

Form Kenarları Arasında Hareket Eden Buton Kontrolü

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
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 DortDonenButon
{
    public partial class Form1 : Form
    {
        int xArtis = 9, yArtis = 9;
       
        Point yeniNokta;

        public Form1()
        {
            InitializeComponent();
        }

        private **** button1_Click(object sender, EventArgs e)
        {
            yeniNokta = new Point(button1.********.X,button1.********.Y);

            //butona tıklandıktan sonra buton hareket etmeye başlasın

            timer1.Start();
        }

        private **** timer1_Tick(object sender, EventArgs e)
        {
            //timer tick olayı gerçekleştiğinde buton hareket yönünde 9 birim ilerlesin
            yeniNokta.X += xArtis;

            yeniNokta.Y += yArtis;

            button1.******** = yeniNokta;

            if (button1.Left <= 0 || button1.********.X >= this.ClientSize.Width - button1.Width)
            {
                xArtis *= -1;
            }

            if (button1.Top <= 0 || button1.********.Y >= this.ClientSize.Height - button1.Height)
            {
                yArtis *= -1;
            }
        }
    }
}
 
Üst