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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:55:36+00:00 2026-06-03T02:55:36+00:00

Looking for some help on a problem Im having sorry if this question has

  • 0

Looking for some help on a problem Im having

sorry if this question has already been asked, I can not find anything similar.

The idea is when a picturebox is clicked changed the image to ON.

If the picture box is held for more than 2 seconds to open a new form and leave the picturebox as OFF.

However if the picturebox is clicked ON and then held for 2 seconds and then returns i need the picturebox state to remain ON.

Here is what I have tried so far.

I believe for this to work correctly I need to stop MouseUp event from occuring.

Is there a way I can stop MouseUp when Tick occurs?

Is there a easier / better way to do this?

Any help would be appreciated.

    private void time_HoldDownInternal_Tick(object sender, EventArgs e)
    { 
        time_HoldDownInternal.Enabled = false;
        time_HoldDownInternal.Interval = 1000;
        form1show.Visible = true;
    }

    private void pb_pictureBoxTest_MouseDown(object sender, MouseEventArgs e)
    {
        mainMenuVariables.mousedown = true;
        time_HoldDownInternal.Enabled = true;
    }

    private void pb_pictureBoxTest_MouseUp(object sender, MouseEventArgs e)
    {
        mainMenuVariables.mousedown = false;
        //MessageBox.Show("mouse up");
        time_HoldDownInternal.Enabled = false;
        time_HoldDownInternal.Interval = 1000;
    }

    private void pb_pictureBoxTest_Click(object sender, EventArgs e)
    {
        if (mainMenuVariables.mousedown == true)
        {
            if (mainMenuVariables.pictureBox == false)
            {
                mainMenuVariables.pictureBox = true;
                pb_pictureBoxTest.Image = new Bitmap(mainMenuVariables.pictureBoxOn);
                return;
            }
            if (mainMenuVariables.pictureBox == true)
            {
                mainMenuVariables.pictureBox = false;
                pb_pictureBoxTest.Image = new Bitmap(mainMenuVariables.pictureBoxOff);
                return;
            }
        }
        if (mainMenuVariables.mousedown == false)
        {
            //nothing
        }
    }
  • 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-03T02:55:37+00:00Added an answer on June 3, 2026 at 2:55 am

    Rather than starting a timer, just record the current time on mouse down. Then in mouse up, check if it has been 2 seconds. e.g:

    private void pb_pictureBoxTest_MouseDown(object sender, MouseEventArgs e)
    {
        mainMenuVariables.mousedown = true;
        mainMenuVariables.mousedowntime = DateTime.Now;
    }
    
    private void pb_pictureBoxTest_MouseUp(object sender, MouseEventArgs e)
    {
        mainMenuVariables.mousedown = false;
        var clickDuration = DateTime.Now - mainMenuVariables.mousedowntime;
    
        if ( clickDuration > TimeSpan.FromSeconds(2))
        {
            // Do 'hold' logic (e.g. open dialog, etc)
        }
        else
        {
            // Do normal click logic (e.g. toggle 'On'/'Off' image)
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully this question is not to confusing, but I can help clear it up
I'm looking for some help to get rid of this error. As i'm running
I wonder if you can help me with a problem I am having, and
I understand that this question has been done to death so I'll apologise in
Im looking to see if anyone can shed some light on a problem im
I'm having some problems with converting some JSON and I'm after some help. This
I'm having this problem with page layout that I've been battling for too long
looking for some help with images referenced within the stylesheet. I have no problems
Looking for some help! I need to split a string at the last occurrence
Looking for some help with optimising the query below. Seems to be two bottlenecks

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.