then closing child form is working this command:
private void listView1_MouseDoubleClick(object sender, EventArgs e)
{
ListViewItem item = listView1.SelectedItems[0];
string s = item.SubItems[6].Text;
q = m;
CommercialOfferEditProperties ob = new CommercialOfferEditProperties(s, q);
ob.FormClosed += new FormClosedEventHandler(ob_FormClosed);
ob.Show(); //show child
}
void ob_FormClosed(object sender, FormClosedEventArgs e)
{
some action
}
But how to run action ob_FormClosed
or run created new action, when in child form is button clicked?
CommercialOfferEditProperties
)That way you will be able to notify the parent.
Example:
//Child form declaration
public class CommercialOfferEditProperties:Form
{
public event EventHandler ButtonClicked;
public void NotifyButtonClicked(EventArgs e)
{
if(ButtonClicked != null)
ButtonClicked(this,e);
}
...
}
Parent form:
private void listView1_MouseDoubleClick(object sender, EventArgs e)
{
ListViewItem item = listView1.SelectedItems[0];
string s = item.SubItems[6].Text;
q = m;
CommercialOfferEditProperties ob = new CommercialOfferEditProperties(s, q);
ob.FormClosed += new FormClosedEventHandler(ob_FormClosed);
ob.ButtonClicked += new EventHandler(ob_ButtonClicked);
ob.Show(); //show child
}
void ob_FormClosed(object sender, FormClosedEventArgs e)
{
//process form close
}
void ob_ButtonClicked(object sender, EventArgs e)
{
//process button clicked
}
You could declare the button as public or (better) create a readonly property exposing your button publicly.
public Button TheButton { get { return button1; } }
and then do
ob.TheButton.Clicked += new ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With