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 8903469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:52:40+00:00 2026-06-15T01:52:40+00:00

I have a PictureBox image in a form which is moving with the mouse

  • 0

I have a PictureBox image in a form which is moving with the mouse movement on the panel.

It’s moving as I want it, however it’s flickering all the time (like refreshes) and I learnt that it’s a problem with forms.

I tried the following lines of code in the constructor of my form but no success:

SetStyle( ControlStyles.ResizeRedraw, true );

SetStyle( ControlStyles.UserPaint, true );

SetStyle( ControlStyles.AllPaintingInWmPaint, true );   

SetStyle( ControlStyles.OptimizedDoubleBuffer, true );    

This is the event handler for the mouse move if it helps to see all the picture. chipHolder is a panel and image is the image imported from file respectively.

private void grid_MouseMove(object sender, MouseEventArgs e)
{ 
      columnPosition = e.X;

      if (columnPosition != -1)
      {
          if (!(columnPosition < 35 || columnPosition > 610))
          {
                chipHolder.Controls.Clear();  
                PictureBox picBox = new PictureBox();
                chipHolder.Controls.Add(picBox);
                picBox.Image = image;
                picBox.Width = image.Width;
                picBox.Height = image.Height;
                picBox.Location = new Point(columnPosition - 33, 0);
                picBox.Show();
          }
      }
      chipHolder.Update();
}

Any ideas?

  • 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-06-15T01:52:41+00:00Added an answer on June 15, 2026 at 1:52 am

    Do not recreate the PictureBox, just move it.

    Just tried this, and image moves without any flickering:

    private void button1_Click(object sender, EventArgs e)
    {
        for (int iter = 0; iter < 500; iter++)
        {
            pictureBox1.Location = new Point(pictureBox1.Left + 1, pictureBox1.Top + 1);
            Application.DoEvents();
            System.Threading.Thread.Sleep(30);
        }
    }
    

    For mouse movements:

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        pictureBox1.Location = new Point(e.X, e.Y);
    }
    
    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        pictureBox1.Location = new Point(e.X + pictureBox1.Left, e.Y + pictureBox1.Top);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GUI window form. I want to set image to pictureBox and
I would like to have a form in which the controls on the form
I have created a picturebox within my panel and I would like to fill
On a form I have a PictureBox , a button to load image in
I have windows form. I have put one loading image in PictureBox When I
hi i have childform and parent form I want to show picture in picturebox
I want programmatically put an image into the form which is not active. Image
I'm implementing panning of a large image in a PictureBox control, and I have
I have the picture box in which the image may be zoomed with different
I have a PictureBox control on a Form that is supposed to draw something

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.