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
  1. Home
  2. General Programming
  3. C#
  4. Mouse Enter/Leave event (global)

Mouse Enter/Leave event (global)

Scheduled Pinned Locked Moved C#
helpcsharp
2 Posts 2 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.
  • S Offline
    S Offline
    sodevrom
    wrote on last edited by
    #1

    Hello, I have a minor problem. I have a Mouse Enter event declared for a Panel Control in c#. The Event is detected correctly when I enter the panel, but if I have other controls in that panel it does not work. So if I drag the mouse over a control from that panel, the mouse enter event is not activated. I hope I am explaining correctly. The ideea would be to get Activate the mouse enter event even if the mouse is entering a control from tha panel. Hope someone can help. Thanks

    T 1 Reply Last reply
    0
    • S sodevrom

      Hello, I have a minor problem. I have a Mouse Enter event declared for a Panel Control in c#. The Event is detected correctly when I enter the panel, but if I have other controls in that panel it does not work. So if I drag the mouse over a control from that panel, the mouse enter event is not activated. I hope I am explaining correctly. The ideea would be to get Activate the mouse enter event even if the mouse is entering a control from tha panel. Hope someone can help. Thanks

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      Two choices: 1. Make all the subcontrol mouseOver events point to the same event handler as the Panel MouseOver Event. 2. Do the same thing, dynamically. That is, handle the ControlAdded and ControlRemoved events of the panel and add/remove the handler on the fly e.g.

      void Panel1ControlAdded(object sender, System.Windows.Forms.ControlEventArgs e)
      {
      e.Control.MouseEnter += this.Panel1MouseEnter;
      }

      void Panel1ControlRemoved(object sender, ControlEventArgs e)
      {
      e.Control.MouseEnter -= this.Panel1MouseEnter;
      }

      However this second options relies on adding the handlers to the ControlAdded and ControlRemoved events before the sub controls are added.

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk

      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