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();
}
摩托车销售模拟器内置菜单中文版
摩托车出售模拟器,又名摩托车销售模拟器,这是一个以摩托车销售
船舶模拟2020最新版
船舶模拟2020是玩法非常有意思的模拟驾驶游戏,高清3d画质
油管主播的生活2内置菜单版
油管主播的生活2内置菜单版是一款模拟养成类游戏,在这里你将体
网吧老板模拟器2手机版
网吧老板模拟器2是非常受欢迎的模拟经营题材手游,在原本的基础
美国警察模拟器巡警2024最新版
美国警察模拟器是一款好玩的模拟手游,游戏中你将扮演一位警察,