So I just read through the Events tutorial on MSDN and am having some problems applying it in my program. I was wondering if someone here could give me a hand.
So I have two forms, a parent called frmInventory and a child called frmNewProduct. The child has a button called btnAccept. Currently, there is a single subscriber called btnAccept_Click subscribed to this event. The existing subscriber is on the child form. I want to add a second subscriber to this event, but this subscriber will be on the parent form. Here is the function on my parent form:
public void updateInventoryFromChild(object sender, EventArgs e)
{
//Not sure how to get this working either, but that is another story
_inventroy = (frmNewProduct)sender._inventory
}
And here is my attempt to subscribe the function to my child’s event:
this.btnAccept.Click += new System.EventHandler((frmInventory)this.Parent.updateInventoryFromChild);
As I stated in one of your previous posts, I think ShowDialog() would be better, for example:
..in your parent form..