Bangladesh Microsoft Technology Community

Come, let's share our idea, opinion, experience & knowledge with each other
Welcome to Bangladesh Microsoft Technology Community Sign in | Join | Help
in Search

dynamic control

Last post 06-03-2008, 02:00 PM by rahat_. 1 replies.
Sort Posts: Previous Next
  •  05-29-2008, 11:08 AM 1063

    dynamic control

    Hi,

    Two questions:

    I. I'm creating a dynamic instance of a windows form for the project, and i wanna do some stuff when it's closed. Can i somehow override it's FormClosing event or is there any other way to do it?

    II. I'm looking for a way to clone a control. I've tryed copying all the properties and controls to the new one - doesn't work so good for some reason. Plus i need the objects to have the same functionality - for example i need the cloned button to call the same events..

    Thanks,

    Sasha

  •  06-03-2008, 02:00 PM 1186 in reply to 1063

    Re: dynamic control

    You can use the different states of the close events :

                Form2 form2 = new Form2();
                form2.FormClosing += new FormClosingEventHandler(form2_FormClosing);
                form2.FormClosed += new FormClosedEventHandler(form2_FormClosed);
                form2.Disposed += new EventHandler(form2_Disposed);
                form2.Show();

            void form2_FormClosing(object sender, FormClosingEventArgs e)
            {
                MessageBox.Show("form2 is going to be closed");
            }
            void form2_FormClosed(object sender, FormClosedEventArgs e)
            {
                MessageBox.Show("form2 is closed");
            }
            void form2_Disposed(object sender, EventArgs e)
            {
                MessageBox.Show("form2 was disposed");
            }
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems