Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bewegung auf Windows Form

Empfohlene Antworten

hallo, ich habe vor ein bild mithilfe einer picturebox auf einer Form zu platzieren.

Dieses Bild soll dann mittels den Richtungstasten in die entsprechende Richtung bewegt werden können...

Wie kann ich das umsetzen??

Hallo Xster,

dazu abonierst du ganz einfach das KeyDown-Event deiner Form, prüfst dort auf die vier Pfeiltasten und setzt dann die Top- bzw. Left-Eigenschaft der PictureBox.

Hallo Xster,

dazu abonierst du ganz einfach das KeyDown-Event deiner Form, prüfst dort auf die vier Pfeiltasten und setzt dann die Top- bzw. Left-Eigenschaft der PictureBox.

Sag mir wenn ich grad gefährliches Halbwissen in die Welt tragen, aber die Location Eigenschaft von einer Picturebox kann man nicht so einfach ändern.

pictureBox.Location.X = 5;

würde einen Error bringen. Ich hab es mal über Point gemacht, habe also using System.Drawing eingebunden.

Richtig, die Location kannst du nicht zur Laufzeit setzen; Left und Top dagegen schon.

pictureBox.Left = 5;

pictureBox.Top = 5;

Naja alternativ kann man die Location zu Laufzeit wirklich setzen.


'Nach Rechts bewegen

pb1.Location = New Point(Picturebox1.Location.X + 5,PictureBox1.Location.Y)


'Nach Oben

pb1.Location = New Point(Picturebox1.Location.X ,PictureBox1.Location.Y -5)


Naja alternativ kann man die Location zu Laufzeit wirklich setzen.


'Nach Rechts bewegen

pb1.Location = New Point(Picturebox1.Location.X + 5,PictureBox1.Location.Y)


'Nach Oben

pb1.Location = New Point(Picturebox1.Location.X ,PictureBox1.Location.Y -5)


Genauso wie ich es getan habe nur das ich ne Referenzvariable hatte.

Point punkt = new Point();

Und dieser immer punkt.Location.x = 5; Werte zugewiesen habe und am Schluss immer.

pictureBox.Location = punkt;

:D

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.