C # - Klavyedeki yön oklarıyla butonu hareket ettirme
3
●1.074
- 31-12-2010, 02:07:31Kimlik doğrulama veya yönetimden onay bekliyor.Merhaba.Uyumadan önce yazıyım dedim
Aşağıda yapılabilecek yöntemlerden birini yazdım. Umarım işine yarar.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { bool b = false; switch (keyData) { case Keys.Left: Guncelle(-1, 0); break; case Keys.Right: Guncelle(+1, 0); break; case Keys.Up: Guncelle(0, -1); break; case Keys.Down: Guncelle(0, +1); break; default: break; } return b; } void Guncelle(int x, int y) { Point p = new Point(button1.Location.X+x,button1.Location.Y+y); button1.Location = p; } - 31-12-2010, 02:15:49
private void Form12_KeyDown(object sender, KeyEventArgs e) { ProcessDialogKey(Keys.KeyCode); } protected override bool ProcessDialogKey(Keys keyData) { if (keyData == Keys.Up) { button1.Location = new Point(button1.Location.X, button1.Location.Y - 50); } if (keyData == Keys.Left) { button1.Location = new Point(button1.Location.X - 50, button1.Location.Y); } if (keyData == Keys.Down) { button1.Location = new Point(button1.Location.X, button1.Location.Y +50); } if (keyData == Keys.Right) { button1.Location = new Point(button1.Location.X + 50, button1.Location.Y); } return base.ProcessDialogKey(keyData); }