Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. C# PictureBox.MouseDown

C# PictureBox.MouseDown

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kselman
    wrote on last edited by
    #1

    I hope this is an easy one. It seems like it should be. I have a pictureBox that I am using as a button. I'm swapping images in and out for up and down states. When the user clicks and holds the mouse down I want it to execute the MouseDown code multiple times until they MouseUp. private void mirrorAdjust_MouseDown(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorDown; //while(MouseDown) ?? Is there a state I can check here? FunctionToRepeatUntilMouseUp(); } private void mirrorAdjust_MouseUp(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorUp; }

    M L 2 Replies Last reply
    0
    • K kselman

      I hope this is an easy one. It seems like it should be. I have a pictureBox that I am using as a button. I'm swapping images in and out for up and down states. When the user clicks and holds the mouse down I want it to execute the MouseDown code multiple times until they MouseUp. private void mirrorAdjust_MouseDown(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorDown; //while(MouseDown) ?? Is there a state I can check here? FunctionToRepeatUntilMouseUp(); } private void mirrorAdjust_MouseUp(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorUp; }

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, In this case you have to work with a timer. (System.Windows.Forms.Timer for example) You set the Enable Property true at Mouse Down. In the tick event code you than add the mousedown code. At mouse up you have to set Enable to false. (Also at MouseLeave to be sure) Hope that helps, All the best Martin

      K 1 Reply Last reply
      0
      • M Martin 0

        Hello, In this case you have to work with a timer. (System.Windows.Forms.Timer for example) You set the Enable Property true at Mouse Down. In the tick event code you than add the mousedown code. At mouse up you have to set Enable to false. (Also at MouseLeave to be sure) Hope that helps, All the best Martin

        K Offline
        K Offline
        kselman
        wrote on last edited by
        #3

        Thanks for the quick reply! Sounds good I will use a Timer then.. Thanks -Kevin

        1 Reply Last reply
        0
        • K kselman

          I hope this is an easy one. It seems like it should be. I have a pictureBox that I am using as a button. I'm swapping images in and out for up and down states. When the user clicks and holds the mouse down I want it to execute the MouseDown code multiple times until they MouseUp. private void mirrorAdjust_MouseDown(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorDown; //while(MouseDown) ?? Is there a state I can check here? FunctionToRepeatUntilMouseUp(); } private void mirrorAdjust_MouseUp(object sender, MouseEventArgs e) { mirrorPictureBox.Image = Resources.MirrorUp; }

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          I have not done this, but I expect you can use a regular Button, give it no text, but add a picturebox to its Controls property, hence combining the best of both. :)

          Luc Pattyn

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups