关闭子窗体 父窗体变量得到值??
A父窗体,B子窗体;窗体A:
public static int ID;
A a1=new A1(tbpcbz.Text);
a1.ShowDialog();
窗体B:
string C="";
public product2(string D)
{
C=D;
InitializeComponent();
}
窗体B:有个按钮button1
点击这个button1,B子窗体关闭,module[0]值给窗体A中的ID;要怎么实现???
winfrom C# --------------------编程问答-------------------- 用事件委托传值可以实现,最简单的用构造函数传参可以实现。
想了解事件问题,多查下资料,一句话是说不清楚的。如果不理清事件委托,贴代码出来也不一定看得懂! --------------------编程问答-------------------- 图简单省事数据量不大,使用静态变量。 --------------------编程问答--------------------
写个代码看看谢谢 --------------------编程问答--------------------
A a1=new B(tbpcbz.Text);
a1.ShowDialog();
string id = a1.B界面顶一个属性; --module[0]
--------------------编程问答--------------------
晕写错了,A窗体那应该写成,B a1=new B(tbpcbz.Text);
a1.ShowDialog(); --------------------编程问答-------------------- public static class info
{
public static string str;
}
form1:
form2 f=new form2 ();
f.showdialog();
form2:
info.str="笑摸楼主小头头";
this.close()
f1 在showdialog后面写代码str 就有值了 --------------------编程问答-------------------- 建议用构成函数传参吧,委托事件有点复杂。 --------------------编程问答--------------------
form2:中,info.str 没有info.... --------------------编程问答--------------------
写个小例子看看谢谢 --------------------编程问答--------------------
B a1=new B();
a1.ShowDialog();
this.ID = a1.Module;
--------------------编程问答-------------------- public A(){}
public class B : Form
{
public string Module
{
return module[0];
}
public B()
{
InitializeComponent();
}
}
public B(){}
public B(A obj){}
在A里面这样声明:B t=new B(this);
注意B有两个构造方法;A一个构造方法,但是给A设置一个变量string temp="";
然后在B类里面obj.temp=module[0];在A里面就直接访问temp这个变量。
补充:.NET技术 , ASP.NET