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. MouseHover Picturebox problem

MouseHover Picturebox problem

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 1 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.
  • D Offline
    D Offline
    dennis_max27
    wrote on last edited by
    #1

    private void pbTextEdit_Click(object sender, EventArgs e)
    {
    Header header = new Header();
    header.Show();

        }
    
        private void pbTextEdit\_MouseHover(object sender, EventArgs e)
        {
            pbTextEdit.Image = Image.FromFile("C:/data/edit\_color.gif");
        }
    

    I'f im hovering it it ain't changing the image? What i wanna do is: Only when I'm moving with my mouse over the picturebox that it is changing from picture then. And when I leave it it is going back to the normal one in the properties. Dennis

    L X 2 Replies Last reply
    0
    • D dennis_max27

      private void pbTextEdit_Click(object sender, EventArgs e)
      {
      Header header = new Header();
      header.Show();

          }
      
          private void pbTextEdit\_MouseHover(object sender, EventArgs e)
          {
              pbTextEdit.Image = Image.FromFile("C:/data/edit\_color.gif");
          }
      

      I'f im hovering it it ain't changing the image? What i wanna do is: Only when I'm moving with my mouse over the picturebox that it is changing from picture then. And when I leave it it is going back to the normal one in the properties. Dennis

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The "hover" event will be fired continuously while your mouse is over the control. Try the OnMouseEnter[^] event to set the picture, and the OnMouseLeave[^] event to reset the original picture, that should do the trick :)

      I are Troll :suss:

      1 Reply Last reply
      0
      • D dennis_max27

        private void pbTextEdit_Click(object sender, EventArgs e)
        {
        Header header = new Header();
        header.Show();

            }
        
            private void pbTextEdit\_MouseHover(object sender, EventArgs e)
            {
                pbTextEdit.Image = Image.FromFile("C:/data/edit\_color.gif");
            }
        

        I'f im hovering it it ain't changing the image? What i wanna do is: Only when I'm moving with my mouse over the picturebox that it is changing from picture then. And when I leave it it is going back to the normal one in the properties. Dennis

        X Offline
        X Offline
        Xelalem
        wrote on last edited by
        #3

        You should use "\" not "/" to write file location use:    private void pbTextEdit_MouseHover(object sender, EventArgs e)         {               pbTextEdit.Image = Image.FromFile(@"C:\data\edit_color.gif"); // not   ("C:/data/edit_color.gif");    }    to reveres the effect use the MouseLeave event: private void pbTextEdit_MouseLeave(object sender, EventArgs e)         {                        pbTextEdit.Image = Image.FromFile("Your privious image here....");    } hope this helps

        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