Form sayfamıza 1 adet pictureBox,timer ve label ekliyoruz. pictureBox'un size 40;40 yapın(boyutu ayarlar) ********u 0;0 yapın ve aşşağıdaki kodları yazın.
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 WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private **** button1_Click(object sender, EventArgs e)
{
}
private **** timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Top == 0)
{
pictureBox1.Left += 10;
label1.Text = "Left:" + pictureBox1.Left.ToString() + "n Right:" + pictureBox1.Right.ToString() + "n Top:" + pictureBox1.Top.ToString() + "n Bottom" + pictureBox1.Bottom.ToString();
}
if (pictureBox1.Left == 400)
{
pictureBox1.Top += 10;
label1.Text = "Left:" + pictureBox1.Left.ToString() + "n Right:" + pictureBox1.Right.ToString() + "n Top:" + pictureBox1.Top.ToString() + "n Bottom" + pictureBox1.Bottom.ToString();
}
if (pictureBox1.Top == 400)
{
pictureBox1.Left -= 10;
label1.Text = "Left:" + pictureBox1.Left.ToString() + "n Right:" + pictureBox1.Right.ToString() + "n Top:" + pictureBox1.Top.ToString() + "n Bottom" + pictureBox1.Bottom.ToString();
}
if (pictureBox1.Left == 0)
{
pictureBox1.Top -= 10;
label1.Text = "Left:" + pictureBox1.Left.ToString() + "n Right:" + pictureBox1.Right.ToString() + "n Top:" + pictureBox1.Top.ToString() + "n Bottom" + pictureBox1.Bottom.ToString();
}
}
private **** Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
}
}
**** = v o i d boşluksuz yazın