日期:2014-05-18  浏览次数:21339 次

c#(winform) 怎么把参数传到ShowDialog()中?
C# code
   
P_str_code = "abc";
frmReceiveInfo frmReceive = new frmReceiveInfo();
frmReceive.ShowDialog();


我想把变量p_str_code传到frmReceive窗体去,请问该加些什么语句?

------解决方案--------------------
在frmReceiveInfo窗体中建一个属性:
private string str;
public string Str
{
get
{
return str;

set
{
str = value;
}
}
然后你就可以:
frmReceiveInfo frmReceive = new frmReceiveInfo();
frmRecevie.Str = P_str_code;
frmReceive.ShowDialog();

就OK了。


------解决方案--------------------
构造函数,可以传值,对象
------解决方案--------------------
在frmReceive的窗体内加入属性
如:
P_str_code = "abc";
frmReceiveInfo frmReceive = new frmReceiveInfo();
frmReceive.Code = P_str_code;
frmReceive.ShowDialog();


------解决方案--------------------
jf