c# nesne haraketleri

alperenbozkurt

Katılımcı Üye
31 Ağu 2011
516
0
El Castillo

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
 
3 Mar 2012
152
0
Gelcen mi
teşekkürler fakat bir paylaşım yapıyorsan ve kodlar biraz uzunsa kopyala yapıştır yerine, ekran görüntüsü destekli veya video destekli anlatım yaparsanız c#'a yeni başlamış arkadaşlar açısından kolay olur.
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.