Autor Beitrag
Sweetiieh
ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 50



BeitragVerfasst: Sa 07.04.12 12:31 
Hallo Community,

mometan bin ich noch ein Anfänger und verzweifel daran, ein PictureBox mit Pfeiltasten zu bewegen.
Mit einen Button habe ich es schon hinbekommen. Da lautet ja einfach der Code:
ausblenden C#-Quelltext
1:
pictureBox1.Left = pictureBox1.Left +1;					


Hat jemand vielleicht ein Beispielcode wie sowas aussehen könnte?
ausblenden C#-Quelltext
1:
2:
3:
4:
if (gedrückt pfeiltaste links)
{
   pictureBox1.Left = pictureBox1.Left +1
}


Mfg Jenny

Moderiert von user profile iconTh69: C#-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 07.04.12 12:35 
Hallo und :welcome:!

Du kannst auf das KeyDown-Ereignis der Form reagieren. Das wird ausgelöst, wenn eine Taste gedrückt wird. Du musst dann nur noch prüfen, welche Taste das war, das steht in den EventArgs drin.

Viele Grüße,
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sweetiieh Threadstarter
ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 50



BeitragVerfasst: Sa 07.04.12 13:02 
user profile iconChristian S. hat folgendes geschrieben Zum zitierten Posting springen:
Hallo und :welcome:!

Du kannst auf das KeyDown-Ereignis der Form reagieren. Das wird ausgelöst, wenn eine Taste gedrückt wird. Du musst dann nur noch prüfen, welche Taste das war, das steht in den EventArgs drin.


Wie kann ich denn auf das KeyDown-Ereignis reagieren? & wie prüfe ich sowas?
daeve
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116
Erhaltene Danke: 3

Windows (XP Pro, 7 Ultimate x64)
C#,WPF,Java,ASP.Net, VS 2010 Ultimate (x86)
BeitragVerfasst: Sa 07.04.12 14:20 
ausblenden C#-Quelltext
1:
2:
3:
4:
protected override void OnKeyDown(KeyEventArgs e)
 {
 if (e.KeyValue == Keys.Right)
 }


Das ist nur Pseudocode aber in etwa so funktioniert das.

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt