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. C# - Events not triggering

C# - Events not triggering

Scheduled Pinned Locked Moved C#
questioncsharpdatabasehelp
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.
  • J Offline
    J Offline
    jgrogan
    wrote on last edited by
    #1

    Hi, A quick question on using events in c#. I have a groupbox on a winform. In that groupbox are a number of textboxes, buttons etc. In order to keep the screen clean, when the mouse is not in the groupbox, some of the buttons are hidden. I use the mouseEnter and mouseLeave events to trigger this. The problem I have is that when a button appears and I click on it, it doesn't trigger the Click event. If I disable the hiding/making visible events then it all works fine. Any ideas? Many thanks, John.

    W 1 Reply Last reply
    0
    • J jgrogan

      Hi, A quick question on using events in c#. I have a groupbox on a winform. In that groupbox are a number of textboxes, buttons etc. In order to keep the screen clean, when the mouse is not in the groupbox, some of the buttons are hidden. I use the mouseEnter and mouseLeave events to trigger this. The problem I have is that when a button appears and I click on it, it doesn't trigger the Click event. If I disable the hiding/making visible events then it all works fine. Any ideas? Many thanks, John.

      W Offline
      W Offline
      WillemM
      wrote on last edited by
      #2

      Can you show the code that is hiding/showing the buttons? There should be also some code to hook up the click events, if you reattach the click event after showing the button it all should work fine :)

      WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

      J 1 Reply Last reply
      0
      • W WillemM

        Can you show the code that is hiding/showing the buttons? There should be also some code to hook up the click events, if you reattach the click event after showing the button it all should work fine :)

        WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog

        J Offline
        J Offline
        jgrogan
        wrote on last edited by
        #3

        Hi Willem, In the designer script, I have the following events defined for the groupbox: this.Conduit_Info_Group.MouseLeave += new System.EventHandler(this.Conduit_Info_Group_Exit); this.Conduit_Info_Group.MouseEnter += new System.EventHandler(this.Conduit_Info_Group_Enter); For the specific button, here is the defined event: this.Conduit_AuthorisedAmount_Graph.Click += new System.EventHandler this.Conduit_AuthorisedAmount_Graph_Click); Here are the above 3 methods: private void Conduit_Info_Group_Enter(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = true; } private void Conduit_Info_Group_Exit(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = false; } private void Conduit_AuthorisedAmount_Graph_Click(object sender, EventArgs e) { } I have also tried changing the enter and exit events as follows: private void Conduit_Info_Group_Enter(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = true; this.Conduit_AuthorisedAmount_Graph.Click += new System.EventHandler(this.Conduit_AuthorisedAmount_Graph_Click); } private void Conduit_Info_Group_Exit(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = false; this.Conduit_AuthorisedAmount_Graph.Click -= new System.EventHandler(this.Conduit_AuthorisedAmount_Graph_Click); } In other words, I've reattached the event after showing the button and removed the event after hiding it, but it doesn't make a difference. Another thing I've tried is removing the event MouseEnter once I've entered the groupbox and reattaching it after I leave. My thinking was that MouseEnter events were swamping the message queue and my button press event was getting lost, but still it wouldn't work! Some days, VB6 just seems much simpler :wtf: Many thanks, John.

        P 1 Reply Last reply
        0
        • J jgrogan

          Hi Willem, In the designer script, I have the following events defined for the groupbox: this.Conduit_Info_Group.MouseLeave += new System.EventHandler(this.Conduit_Info_Group_Exit); this.Conduit_Info_Group.MouseEnter += new System.EventHandler(this.Conduit_Info_Group_Enter); For the specific button, here is the defined event: this.Conduit_AuthorisedAmount_Graph.Click += new System.EventHandler this.Conduit_AuthorisedAmount_Graph_Click); Here are the above 3 methods: private void Conduit_Info_Group_Enter(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = true; } private void Conduit_Info_Group_Exit(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = false; } private void Conduit_AuthorisedAmount_Graph_Click(object sender, EventArgs e) { } I have also tried changing the enter and exit events as follows: private void Conduit_Info_Group_Enter(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = true; this.Conduit_AuthorisedAmount_Graph.Click += new System.EventHandler(this.Conduit_AuthorisedAmount_Graph_Click); } private void Conduit_Info_Group_Exit(object sender, EventArgs e) { this.Conduit_AuthorisedAmount_Graph.Visible = false; this.Conduit_AuthorisedAmount_Graph.Click -= new System.EventHandler(this.Conduit_AuthorisedAmount_Graph_Click); } In other words, I've reattached the event after showing the button and removed the event after hiding it, but it doesn't make a difference. Another thing I've tried is removing the event MouseEnter once I've entered the groupbox and reattaching it after I leave. My thinking was that MouseEnter events were swamping the message queue and my button press event was getting lost, but still it wouldn't work! Some days, VB6 just seems much simpler :wtf: Many thanks, John.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          I wouldn't bother with detaching/reattaching; just attach it as usual and leave it.

          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