Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows
hi all
 
How to know usercontrol(form) is closing or not?
 
let me know
 
my code
 
 
//pageload
this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
 
void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            UpdateAll();
        }
 
 
it's not working
 
Thanks in advance
Posted 28-Aug-12 4:04am
U@0071K
Edited 28-Aug-12 4:09am
v3
Comments
Legor at 28-Aug-12 9:08am
   
What do you mean by "Its not working" ? What isn't working.
Wes Aday at 28-Aug-12 9:08am
   
"it's not working".. is not a helpful description of any kind of a problem. What is not working? How does it not perform to your satisfaction? Does the event handler not get called? Does the UpdateAll() method not execute? Did the city burn down when you ran this code?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It works fine for me:
void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
    {
    Console.WriteLine("Form closing");
    }
 
private void UserControl1_Load(object sender, EventArgs e)
    {
    ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
    }
Check that you have hooked up the Load event handler for your control.
  Permalink  
Comments
ridoy at 28-Aug-12 10:03am
   
good..+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 424
2 OriginalGriff 360
3 Abhinav S 250
4 CHill60 240
0 Sergey Alexandrovich Kryukov 10,102
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100