I have a Form MainForm which inherits DockContent and even registered the mousedown and keypress event in the initialization of form. But none of these events get triggered and really don't know what could be the reason.
Below is the code :
using WeifenLuo.WinFormsUI.Docking;
public partial class MainForm : DockContent
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.MainForm_Load);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MainForm_KeyPress);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyUp);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseDown);
}
}
private void MainForm_MouseDown(object sender, MouseEventArgs e)
{
Copy.Show(Cursor.Position);
}
On the right or left click on form i want to show context menu with item "Copy". But mousedown event or even the keypress event does not trigger.
The mouse events only work for the top control so they won't fire for the form controls when there is another control on top.
there you can find some workaround:
How do I grab events from sub-controls on a user-control in a WinForms App?
anyway I created a simple winform app with your code and everything works fine so you have definitely something that is swallowing all your events