Home > Net >  How can I change another user controls in the label text value
How can I change another user controls in the label text value

Time:10-06

As title, I created two user controls u1 and u2, there a label control u1, u2 has a button, how can I change after u2's button in the u1 label1. The Text of the Text

CodePudding user response:


 namespace WindowsFormsApp1 
{
Public partial class Form2: Form
{
Public Form2 ()
{
InitializeComponent();
}

Public void SetLabel (string value)
{
This. Label1. Text=value;
}
}
}


 namespace WindowsFormsApp1 
{
Public partial class Form1: Form
{
Form2 form;
Public _click ()
{
InitializeComponent();
}

Private void Form1_Load (object sender, EventArgs e)
{
Form=new Form2 ();
Form. The Show ();
}

Private void button1_Click (object sender, EventArgs e)
{
Form. SetLabel (" 123321 ");
}
}
}

CodePudding user response:

You have to write this method much more label, a little bit of a problem

CodePudding user response:

Can set the label into public
Throw it to the delegate can also
Write a way out and into
Get a reflex can also
Have a proxy access also OK
Get into messaging also into

According to the way you ask questions, it is recommended that the former three, at the back of the three kinds of understanding the later

CodePudding user response:

http://bbs.csdn.net/topics/390128592

CodePudding user response:

Is changed to another Form to control value?

Form2 f2=new Form2 (" value ");

Write a constructor Form2 inside Public Form2 (string value) {label. The text=value};


This also line

CodePudding user response:

The
reference 3 floor wanghui0380 response:
can set the label into public
Throw it to the delegate can also
Write a way out and into
Get a reflex can also
Have a proxy access also OK
Get into messaging also into

According to the way you ask questions, it is recommended that the top three, three at the back of the later understand the

Two UserControl can also like this

CodePudding user response:

refer to fifth floor rabbit family - second brother reply:
is changed to another Form to control value?

Form2 f2=new Form2 (" value ");

Write a constructor Form2 inside Public Form2 (string value) {label. The text=value};


So also line

The value of the UserControl in controls
  •  Tags:  
  • C#
  • Related