Form bezárásának visszavonása

Szóval nagyjából két perc MSDN keresgélés után megtaláltam a múlt heti problémát, nevezetesen, hogy ha nem akarjuk, ne záródjon be a program. Nagyon egyszerű!

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Biztosan ki akarsz lépni?","Kilépés",MessageBoxButtons.YesNo) == DialogResult.No)
e.Cancel = true;
}

A Closing() ugyanis kap egy CancelEventArgs típusú változót, és ha ennek a Cancel tulajdonságát true-ra állítjuk, akkor nem zárul be a progi. Ebben az esetben ha egy gomb, vagy menü kattintás-eseményébe bepakoljuk a this.Close() függvényt, akkor is vissza lehet vonni, illetve a kis X-re kattintva is működik.

Bátrabbak kipróbálhatják, hogy kiveszik a MessageBox-os feltételt, én nem mertem! 🙂

Advertisements

4 Responses to Form bezárásának visszavonása

  1. nyuszko says:

    Köszi, nagyun tuti! 🙂

  2. XRumer is the best tool for promotion!
    It’s have CAPTCHA recognizer, email verificator, and a lot of other functions…

    But. I forgot link to it 😦

    Can you give me URL to the XRumer description? screenshots, etc.

    Thank you

  3. Hello
    Such girls stead predominantly sloppy photos of low distinction in their questionnaires.
    You can only analyse their faces on such photos, but you can mark their sprightliness and surroundings,
    which they masquerade as with frame of mind. They error the biggest hint at of the formal columns,
    but in the “yearn answers” they disparage something ridiculous and completely deprecating.
    Such girls look for secluded and sincere relationships. They are lascivious, logical and they don’t bid

    Russians ladies, ukrainian women and russian girls seeking men for wedlock

    G’fall

  4. Velvet Deer Antler has long been known and used in traditional Oriental medicine as a powerful stimulant of sexual desire and stamina and general physical performance.
    Visit official website: sexual performance supplement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: