最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 的winform中窗体之间跳转如何传值
时间:2022-06-25 05:46:31 编辑:袖梨 来源:一聚教程网
asp教程.net 的winform中窗体之间跳转如何传值
使用attribute
public partial class form1 : form
{
private void button1_click(object sender, eventargs e)
{
form2 frm2 = new form2();
frm2.show(this);
}
}
public partial class form2 : form
{
private void button1_click(object sender, eventargs e)
{
form1 frm1 = (form1)this.owner;
((textbox)frm1.controls["textbox1"]).text = this.textbox2.text;
this.close();
}
}
还可使用委托
使用委托实现两个窗体的交互:
// 主窗体中
fromb frm = new fromb("hello a");
frm.onreportprogress = new doreportprogress(onreportprogress);
frm.showdialog(); // 显示窗体
private void onreportprogress(string str)
{
messagebox.show(str);
}
// 子窗体
public delegate void doreportprogress(string strinfor);
public doreportprogress onreportprogress;
public fromb(string str) // 传入父窗体的值
{
initializecomponent();
messagebox.show(str);
}
public void button1()
{
if(onreportprogress!=null)
onreportprogress("hello b"); // 调用委托将值返回给父窗体
}
相关文章
- 波场 05-02
- 狗狗币能涨到5万美刀吗 05-02
- 游戏dau下降 05-02
- btc行情 05-02
- 从零开始学虚拟货币交易 05-02
- 比特币实时交易策略 05-02