Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8333137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:55:06+00:00 2026-06-09T02:55:06+00:00

So I just read through the Events tutorial on MSDN and am having some

  • 0

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:55:08+00:00Added an answer on June 9, 2026 at 2:55 am

    As I stated in one of your previous posts, I think ShowDialog() would be better, for example:

    class ChildForm : Form {
        private Inventory _inventory;
    
        public Inventory MyInventory {
            get {
                return _inventory;
            }
        }
    
        private void btnAccept_Click(object sender, EventArgs e) {
            _inventory = <set_inventory_here>;
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
    

    ..in your parent form..

    public void updateInventoryFromChild(object sender, EventArgs e)
    {
        ChildForm childForm = new ChildForm();
        if (childForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
            _inventory = childForm.MyInventory;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to split just a string I've read in through a csv
I have read through the documentation for Winsock2 on MSDN, but I still need
I just read an article on www.songho.ca which indicates that a projection matrix is
I just read on this answer (answer has since been removed) and I'm sure
I just read in Code Complete that you should not use exceptions for flow
I just read a blog which says ...methods that couldn’t be inlined previously because
I just read this great answer from BalusC about how to upload files with
I just read this requirement on a job listing: Aware of the pitfalls of
I just read this: http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx I was under the impression that overwriting Object or
I just read about the breadth-first search algorithm in the Introduction to Algorithms book

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.