Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

C#: Disabling FormClosing event

$
0
0

Hi,

Is there a way that I can an event I created when another event occur?

I need to disable the FormClosing event when I click a certain button because the FormClosing event I have shows a pop up message and I dont want it popping up unless I am really closing the application. The button Im clicking is a link to redirect me to another form so it's really not closing the first form but the popup message always appear so what Im thinking is can I disable the formclosing event when i click the link button?

        private void HomePage_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to close Application?\n\nPress OK to continue, or Cancel to keep Application open.", "Exit", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                e.Cancel = true;
            }
            
        }

     private void goToViewLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenPage f = new OpenPage();
            this.Hide();
            f.Show();
            

        }


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>