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

  • SEARCH
  • Home
  • 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 850125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:12:46+00:00 2026-05-15T07:12:46+00:00

Wierd behaviour when passing values to and from second form. ParameterForm pf = new

  • 0

Wierd behaviour when passing values to and from second form.

ParameterForm pf = new ParameterForm(testString);

works

ParameterForm pf = new ParameterForm();
pf.testString="test";

doesn’t (testString defined as public string)

maybe i’m missing something? Anyway I’d like to make 2nd variant work properly, as for now – it returns null object reference error.

Thanks for help.

Posting more code here:

calling

Button ParametersButton = new Button();
ParametersButton.Click += delegate
                {
                    ParameterForm pf = new ParameterForm(doc.GetElementById(ParametersButton.Tag.ToString()));
                    pf.ShowDialog(this);
                    pf.test = "test";
                    pf.Submit += new ParameterForm.ParameterSubmitResult(pf_Submit);
                };

definition and use

   public partial class ParameterForm : Form
    {
        public string test;
        public XmlElement node;
        public delegate void ParameterSubmitResult(object sender, XmlElement e);
        public event ParameterSubmitResult Submit;

        public void SubmitButton_Click(object sender, EventArgs e)
        {
            Submit(this,this.node);
            Debug.WriteLine(test);
        }
     }

result:
Submit – null object reference
test – null object reference

  • 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-05-15T07:12:47+00:00Added an answer on May 15, 2026 at 7:12 am
    • pf.ShowDialog(this); is a blocking call, so pf.Submit += new ParameterForm.ParameterSubmitResult(pf_Submit); is never reached: switch the order.

    • Submit(this,this.node); throws a null object reference because no event is assigned to it (see above). Generally, you should always check first: if (Submit != null) Submit(this,this.node);

    • You should change “pf.ShowDialog(this);topf.Show(this);` so that your main form isn’t disabled while your dialog box is open, if that’s what you want, or use the model below (typical for dialog boxes.)


    I’m not sure what pf_Submit is supposed to do, so this might not be the best way to go about it in your application, but it’s how general “Proceed? Yes/No” questions work.

    Button ParametersButton = new Button();
    ParametersButton.Click += delegate
        {
            ParameterForm pf = new ParameterForm(testString);
            pf.ShowDialog(this); // Blocks until user submits
            // Do whatever pf_Submit did here.
        };
    
    public partial class ParameterForm : Form
    {
        public string test;     // Generally, encapsulate these
        public XmlElement node; // in properties
    
        public void SubmitButton_Click(object sender, EventArgs e)
        {
            Debug.WriteLine(test);
            this.Close(); // Returns from ShowDialog()
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 452k
  • Answers 452k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is no way to know how much time is… May 15, 2026 at 9:12 pm
  • Editorial Team
    Editorial Team added an answer I figured it out. When you reference the ODP you… May 15, 2026 at 9:12 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately you can't get a published date. We have to… May 15, 2026 at 9:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.