A页面ShowDialog B页面,B页面关闭时,怎么把一个变量给A页面
解决方案 »
- 为什么调用WCF操作数据库时有时候快,有时候慢,这是什么原因,解决不了了,求救??
- C#如何在外部程序的文本框中输入文字?
- 新手提问: WinForm HttpRequest Session相关的问题
- 这SqlDataAdapter的update难道就这么难用,兄弟们帮我看看,怎么会没有效果?
- 请问什么是SaveAsFile.dll控件?哪有介绍的文章和这SaveAsFile.dll控件下载啊?能不能给个网址?到处找了,没找到什么东西啊!谢谢!
- winform 在textbox里面输入数据是,隔1秒没有输入就执行代码
- 菜鳥問題!
- 请教有个DataTable
- StructLayout类是干什么用的,它有什么用,什么时候用它呀?????????????
- 求解
- 求一个小程序的写法
- Combox控件加载内容方法
{
var result=showModalDialog('../customers/customer_select.aspx?facid=<%=factid %>','customerpage','dialogWidth:500px;dialogHeight:400px;center:yes;help:no;resizable:no;status:no'); //打开模态子窗体,并获取返回值
//window.open('../_popup/customer_select.aspx');
if (result != undefined)
{
document.getElementById("hid_customercode_2").value=result.split("^")[0]; //返回值分别赋值给相关文本框
document.getElementById("tb_customername_2").value=result.split("^")[1];
}
} function select(code,name,address,tel,fax,postcode)
{
window.returnValue= code + "^" + name + "^" + address + "^" + tel + "^" + fax + "^" + postcode; //返回值
window.close();
}ondblclick="javascript:select('<%# Eval("customercode") %>','<%# Eval("customername") %>','<%# Eval("address") %>','<%# Eval("tel") %>','<%# Eval("fax") %>','<%# Eval("postcode") %>');"
传到B页面
就可以了
A页面:
MyArg temp = new MyArg();
B b = new B(temp);
b.ShowDialog();
你在B 中修改 temp 返回A时 值也改变了楼主没有分清楚值传递和地址传递
B b = NEW B(ref i);
b.showDialog();
B b = NEW B();
b.showDialog(); i = b.i;
http://dotnet.aspx.cc/article/00000000-0000-0000-0000-00000000000f/read.aspx
{
B b = new B();b.FormClosing+=new FormClosingEventHandler(B_FormClosing);
}
private void B_FormClosing(object sender, EventArgs e)
{
Form b = sender as Form;
b.变量=。。
}
方法1:用static变量配合返回状态方式class C { static string c; }
class B
{
private void btnOk_Click(...)
{
C.c = "来自B";
this.DialogResult = DialogResult.OK;
this.Close();
}
}
class A
{
private void ss()
{
B b = new B();
if (b.ShowDialog() == DialogResult.OK) MessageBox.Show(C.c);
}
}
方法2:用委托class A
{
private void aa(string a)
{
MessageBox.Show(a);
} private void ss()
{
B b = new B(aa);
b.ShowDialog();
}
}
class B
{
public delegate void BB(string b);
private BB _bb; public B(BB bb) { _bb = bb; } private void btnOk_Click(...)
{
this.Close();
if (_bb != null) _bb("来自B");
}
}
{
public B()
{
InitializeComponent();
}
public delegate void MyDelegate(string str);
public event MyDelegate mydelegate;
private void button1_Click(object sender, EventArgs e)
{
if (mydelegate != null)
mydelegate("this is B");
this.Close();
}
} public partial class A : Form
{
public A()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
B b = new B();
b.mydelegate += TestDelegate;
b.Show();
}
public void TestDelegate(string str)
{
label1.Text = str;
}
}
xzmx.htbh = htbh.Text.ToString();
DialogResult dr = xzmx.ShowDialog();
if (dr == DialogResult.OK)
{ }
B页面操作完 后
A.bl = ""; //这里你要B到A的值 this.DialogResult = DialogResult.OK;