PerformClick is not working for second time

Joined
Sep 28, 2012
Messages
1
Reaction score
0
I have a dialog with a button (marked public).
Somewhere in another page, I am launching the dialog and registering Load event and firing the button click using button.PerformClick

This works fine when I create instance of dialog every time where i am planning to call. but if I reuse the dialog, second time onwards the button click event is not firing

publicpartialclassdlg : Form
{ // button1 is public
public dlg() { InitializeComponent(); }
privatevoid button1_Click(object sender, EventArgs e) { MessageBox.Show("XXX"); }
}


dlg d = newdlg(); // option 1
void Test()
{
// dlg d = new dlg(); // option 2
d.Load += newEventHandler(delegate(object a, EventArgs ty) { d.button1.PerformClick(); });
d.ShowDialog();
}

If I enable option 2, I would get message "XXX" each time i call the Test method. If I enable option 1, first time it popups the message and not for the consequent times.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top