Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Trying to pass data object between 2 forms using constructor in C#

$
0
0

I'm trying to pass the string 'IDdateOfBirth' from the class 'ApplicationForm' to 'IDForm' and insert it into a richtextBox but my constructor doesn't seem to be passing it as it still says 'IDdob doesn't exist in current context'

namespace PROG2B_Assign1
{
    public partial class ApplicationForm : Form
    {
        string IDday;
        string IDmonth;
        string IDyear;
        string IDyearRemove;
        string IDdateOfBirth;

        public ApplicationForm()
        {

            InitializeComponent();


            IDday = Convert.ToString(comboBox2.Text);
            IDmonth = Convert.ToString(comboBox2.Text);
            IDyear = Convert.ToString(comboBox2.Text);
            IDyearRemove = IDyear.Remove(0, 2);
            IDdateOfBirth = IDyearRemove + IDmonth + IDday;
        }

       //Constructor to pass IDdateOfBirth

        public ApplicationForm(string IDdob)
        {
            IDdateOfBirth = IDdob;
        }

namespace PROG2B_Assign1

    public partial class IDForm : Form
    {
        public IDForm() 
        {
            InitializeComponent();
        }

        private void GenerateButton_Click(object sender, EventArgs e)
        {
            ApplicationForm Form = new ApplicationForm(IDdob); // Here is says that it doesn't exist in the current context
            richTextBox1.AppendText(IDdateOfBirth); // string I want in the richTextBox of this form
        }
    }
}


Viewing all articles
Browse latest Browse all 12583

Trending Articles