Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4608088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:47:42+00:00 2026-05-22T00:47:42+00:00

I am attempting to move a PictureBox(picUser) up and down via the key press

  • 0

I am attempting to move a PictureBox(picUser) up and down via the key press events. I am newer to C# and am able to do this via VB. As such I am confused as to what the problem is with the following code:

    private void picUser_keyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        if (e.KeyCode == Keys.W)
        {
            picUser.Top -= 10;
        }
    }

There is no “error” with the code, the picturebox just doesn’t move.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:47:43+00:00Added an answer on May 22, 2026 at 12:47 am

    A PictureBox has no KeyDown event. It has a PreviewKeyDown instead and requires the PictureBox to have the focus.

    I would suggest to use the KeyDown of the form that host the PictureBox instead and use the same exact code:

    public Form1()
    {
         InitializeComponent();
         this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
    }
    
    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
         if (e.KeyCode == Keys.W)
         {
             picUser.Top -= 10;
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to move all controls on a form down or up by
Attempting to modify the code from this page . Here's the problem code: #include
I'm attempting to move the camera via gluLookAt in my OpenGL app similar to
I am attempting to move to XE2 from Delphi 6. When I compile and
I am attempting to use the code found in the answer here: Directory.Move doesn't
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to move an uploaded file so that it is saved in the directory,
In the below code I am attempting to move the three buttons to the
I'm attempting to move a web app we have (written in Perl) from an
I'm attempting to move from VS2008 to VS2010 and want to also upgrade the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.