Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My code below:

private frmintro intro;

Main Form1:
private void pictureBox3_Click(object sender, EventArgs e)
        {           
            intro = new frmintro();
            intro.LabelText = "LabelChanged!";
            intro.Show();
            
        }


another form:
public string LabelText
        {
            get
            {
                return label1.Text;
            }
            set
            {
                label1.Text = value;
            }
        }

My code works, it changes the label text, but it creates another form and its floating out of panel.

What I have tried:

So i docked the panel using:

private void pictureBox3_Click(object sender, EventArgs e)
        {           
            intro = new frmintro() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true };
            intro.LabelText = "LabelChanged!";
            intro.Show();
            
        }
Posted
Updated 10-Mar-22 9:43am

1 solution

A correct way to achieve that is described here:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]

I'd strongly suggest to read these articles very carefully and ... Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900