0

I have a panel at top with the dock option 'Top' However events are not firing like;

    private void pnlHeader_MouseClick(object sender, MouseEventArgs e)
    {
        MessageBox.Show("test");
    }

Added event

Red area where i click enter image description here

All others panels are working good which they all are docked too.

What should be the cause?

  • The usual cause is that the event(s) is/are not [hooked up](http://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=14|0.0000#33276161) - Check in the properties-events pane! - Another could be that it is covered. – TaW Jun 27 '17 at 07:44
  • @TaW no, all of this done already. Still same. –  Jun 27 '17 at 07:48
  • To be sure you can also give it a Backcolor and do a BringToFront in a test button click. Can you add a button to it and click the button? Also test the size of the panel! – TaW Jun 27 '17 at 07:51
  • Are you sure there's nothing on the panel that is hiding it and getting the clicks? – Jcl Jun 27 '17 at 07:52
  • I did what you said, all of the same. Also edited question. @TaW –  Jun 27 '17 at 07:56
  • There is however, their size is obvious. I added an image.@Jcl –  Jun 27 '17 at 07:57
  • Hm, and when you click the panel in the desiger it shows up? Sounds strange! – TaW Jun 27 '17 at 07:59
  • @TaW yes, its all strange. –  Jun 27 '17 at 08:00
  • Last resort usually is removing the fishy control and replacing it with a fresh one. emove the buttons from it first, of course. then test the new one, then move the buttons back. if that helped the curious one might want to study the old deisgner.ce file with the new one.. – TaW Jun 27 '17 at 08:02
  • Are you using uwp or wpf? or even dockpanel suite? – gymni f Jun 27 '17 at 08:58

1 Answers1

1

If your Panel contains other elements, and you're clicking on these elements, then the MouseClick event won't be fired (I just tested that). The solution is to whether put the same MouseClick event on the inner elements, or laying an invisible surface on the Panel in order to get the MouseClick event.

thi
  • 71
  • 1
  • 9