I am trying to get a text value from NameForm and pull it in Welcome as a label value.
What I have so far, when the Welcome page comes up, it does not give the value of the text but if you click on the label field, it pops up with the NameForm screen. After you enter name again on the NameForm screen, it will show in Welcome.

Screens should be:

NameForm - enter name and click submit to go to Welcome.
Welcome - this has a label field in it that should populate with the name that was entered on the NameForm.

public partial class NameForm : Form
        private string fullname = " ";

        public string nameValue
        { get { return fullname; } }
        public void SubNameBtn_Click(object sender, EventArgs e)
            this.AcceptButton = SubNameBtn;   

            User user = new User();

            user.FirstName = fNameTxt.Text;
            user.LastName = lNameTxt.Text;

            fullname = fNameTxt.Text;    \\using only fNameTxt till figured out
public partial class Welcome : Form
        public Welcome()

        private void WelNameLbl_Click(object sender, EventArgs e)
            NameForm frm = new NameForm();
            WelNameLbl.Text = frm.nameValue;


I recently had a problem like this.
I found a site about it but I can't find it now.

So basically I passed the main form as an argument to the login form.
Like this:

public int a = 100;
        public Mainform() { // I created the loginform in Mainform
        LoginForm Name = new LoginForm(this);  //And pass the Mainform as an argument

This is the loginForm

Mainform parent;
        public LoginForm(Mainform parentform) {
        this.parent = parentform;

Now you can call items in the Mainform if they are public.
Like this:

parent.a = 0;

Edited 6 Years Ago by Klaurac: n/a

This article has been dead for over six months. Start a new discussion instead.