0

Morning Guys.. Have a Monday Morning Blank out here!

I have the following Debug code setup:

         //XML Load of Document. This loads the XML Document and the value of a Single Node then inputs this to a text box//
            XmlDocument doc = new XmlDocument();
            doc.Load("C:\\twDB.xml");
            XmlNode node = doc.SelectSingleNode("/DataBases/DataBase/Connection");
            this.textBox1.Text = node.InnerText;

Currently shows the path of XML in text box for Debugging.

However - How do I show that same information in form2.cs textbox1 ?

Minds gone blank.. need more coffee.

Regards
Mark.

3
Contributors
5
Replies
15
Views
4 Years
Discussion Span
Last Post by sundog1
Featured Replies
  • Okay, there's a couple of ways you can do it. Firstly, have a public field through which you can set the value. Secondly, call a public method which sets the value explicitly. First: Form2 secondForm = new Form2(); secondForm.ConnectionString = textBox1.Text; secondForm.Show(); .... In Form2: OnLoad(object sender, EventArgs evt) { … Read More

0

Morning Kesuekiame,

It's called via a Label in the 1st form.

      private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //Opens Second Form - Not Used as yet//
            Form2 secondForm = new Form2();
            secondForm.Show();
        }

regards
Mark.

Edited by sundog1

0

You can create a constructor for Form2 that accepts a string parameter and pass that value when showing the second form. Be sure to set the textbox text on second form on Init().

1

Okay, there's a couple of ways you can do it.

Firstly, have a public field through which you can set the value.
Secondly, call a public method which sets the value explicitly.

First:

Form2 secondForm = new Form2();
secondForm.ConnectionString = textBox1.Text;
secondForm.Show();


....

In Form2:

OnLoad(object sender, EventArgs evt)
{
    textBox1.Text = ConnectionString;
}

Second:

Form2 secondForm = new Form2();
secondForm.SetConnectionString(textBox1.Text);
secondForm.Show();

....

Form2:

public void SetConnectionString(String connectionString)
{
    textBox1.Text = connectionString;
}

Alternatively, use the constructor. The best way would be to use a configuration object that you can call from your second form (Singleton accessor) so you needn't pass the data around.

0

Ahhh..

There we go. All done... Thanks guys.. Coffee has finally kicked in.

All sorted

Thanks as always.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.