更新时间:2022-10-17 11:15:31
Form1按钮事件public string kmp = ;
private void Button_Click( object sender,EventArgs e)
{
Form2 qu = new Form2();
qu.ShowDialog();
lable.text = kmp;
}
Form2按钮事件private void Button_Click( object sender,EventArgs e)
{
Form1 l = new Form1();
l.kmp = textbox.text;
}
在表格2上创建一个属性
public string LblText
{
set {lable.text = value ;}
}
并从Form1(在显示对话框之前)设置此属性值lockquote>public Int kmp = 0 ;
private void Button_Click( object sender,EventArgs e)
{
kmp = ur value ;
Form2 qu = new Form2();
qu.ShowDialog();
}
private void Form2_Load( object sender,EventArgs e)
{
Form1 l = new Form1();
label1.text = l.kmp.toString();
}
或private void Button_Click( object sender,EventArgs e)
{
Form2 qu = new Form2(ur value 跨度>);
qu.ShowDialog();
}
public Form2( int l)
{
InitializeComponent();
label1.text = l.toString();
}
how to set value of a label in FORM_2 from the local variable ID from FORM_1?
Form1 button eventpublic string kmp=""; private void Button_Click(object sender, EventArgs e) { Form2 qu = new Form2 (); qu.ShowDialog(); lable.text =kmp; }
Form2 button eventprivate void Button_Click(object sender, EventArgs e) { Form1 l = new Form1(); l.kmp = textbox.text; }
Create a property on Form 2public string LblText { set { lable.text = value ;} }
and set value to this property from Form1 (before show dialog)
public Int kmp=0; private void Button_Click(object sender, EventArgs e) { kmp=ur value; Form2 qu = new Form2 (); qu.ShowDialog(); }
private void Form2_Load(object sender, EventArgs e) { Form1 l = new Form1(); label1.text= l.kmp.toString() ; }
Orprivate void Button_Click(object sender, EventArgs e) { Form2 qu = new Form2 (ur value); qu.ShowDialog(); }
public Form2(int l) { InitializeComponent(); label1.text=l.toString(); }