Link to home
Create AccountLog in
Avatar of jschmuff
jschmuffFlag for United States of America

asked on

variables from form1 passing to form2

I am having issue's please help I get this error:

Form1.cs(28,19): error CS0117: 'Variable_passing.Form2' does not contain a definition for 'textBox2'

here is my code for program.cs:


public class Names
    {
        private string name;
 
        public string Name
        {
            get
            {
                return (this.name);
            }
            set
            {
                this.name = value;
            }
        }
    }
 
Here is my code from form1.cs:
 
    public partial class Form1 : Form
    {
        Names names = new Names();
        Form2 form2 = new Form2();
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            names.Name = textBox1.Text;
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            form2.textBox2.Text = names.Name;
            form2.Show();
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Priest04
Priest04
Flag of Serbia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of jschmuff

ASKER

I got it thanks pal.