C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,309 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
when i right click the form, form will be closed but, event not firing. i don't know why...?
i am not able to paste the code. i have taken the screenshot. below code for your reference.
Have you added :
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing);
(automatically added when you double-click in the Designer)
Try the following
const int WM_CONTEXTMENU = 0x007B;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_CONTEXTMENU)
{
m.Result = IntPtr.Zero;
Close();
}
else
{
base.WndProc(ref m);
}
}
Type Closing += press TAB which should give you an event e.g. where I added a MessageBox
Once you have right clicked the MessageBox is shown then the form closes.