troubleshooting Question

simple c# does not exist in the current context question

Avatar of sydneyguy
sydneyguyFlag for Australia asked on
C#
14 Comments2 Solutions1047 ViewsLast Modified:
have set up two forms form1 and form2, i have a messagebox.show on form2 and from form1 want to run the cold that displays the message on form2 , have been reading but still a bit vague on how to get the other function to run by setting up the correct scope to be able to reference it.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace testsiteforconnectionbetweenforms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            msgdisplay();
        }
       
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace testsiteforconnectionbetweenforms
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void msgdisplay()
        {
            MessageBox.Show("hello world");
        }
    }
}
ASKER CERTIFIED SOLUTION
Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Join our community to see this answer!
Unlock 2 Answers and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros