I am trying to fire the mouse right button click event of a Panel and call a function but its not firing. This is my code:
private void viewscreen_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
generate_editpanel();
}
}
“viewscreen” is a Panel. And my designer code is:
// viewscreen
//
this.viewscreen.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.viewscreen.Location = new System.Drawing.Point(208, 16);
this.viewscreen.Name = "viewscreen";
this.viewscreen.Size = new System.Drawing.Size(370, 289);
this.viewscreen.TabIndex = 0;
this.viewscreen.MouseClick +=
new System.Windows.Forms.MouseEventHandler(this.viewscreen_MouseClick);
Can any one help me?
The video object in your Panel must be covering up the whole area (docked) of the Panel. In that case the event of the panel wont’t get fired because all the clicks will take place on the video object.
But if you still wish to fire the event of the panel you can modify the form designer code like this:
Here I have docked a PictureBox(pictureBox1) in the panel(viewscreen). And now in the form code you can test like this: