最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 窗口之间值、控件的传递值
时间:2022-06-25 04:24:59 编辑:袖梨 来源:一聚教程网
asp教程.net 窗口之间值、控件的传递值
一、值的传递,很简单,因为在同一名称空间下,所以只需在要提供值的窗口里将值声明为public后,就可以在要引用值的窗口里通过“类名.变量名”使用了。如:
mainwindow.cs里:
public string test;
private void button2_click(object sender, routedeventargs e)
{
mytest test = new mytest();
test.showdialog();
}
在mytest.cs里:
public mytest()
{
initializecomponent();
mainwindow mw= new mainwindow();
this.content = mw.test;
}
二、控件的传递,和值传递类似,但需要更改子窗口的构造函数,在主窗口初始化时传递控件,如,我们现在传一个datagrid控件,并攻取它选中的值。
在mytest.cs里:
public mytest(datagrid mydg)
{
dg = mydg;
initializecomponent();
albums alb=new albums();
alb=dg.items[dg.selectedindex] as albums;
this.content = alb.title;
}
mainwindow.cs里:
private void button2_click(object sender, routedeventargs e)
{
mytest test = new mytest(datagrid1);
test.showdialog();
}
相关文章
- 《塞尔达传说王国之泪》海利亚盾刷新耐久方法 海利亚盾怎么刷新耐久? 05-03
- 崩坏星穹铁道托帕突破材料一览 05-03
- TokenPocket钱包苹果版 05-03
- kdpay钱包app官网下载安卓版 05-03
- MGC钱包下载2024最新版 05-03
- 黑币钱包中文版 05-03