public string st;
public From1()
{
InitializeComponent();}
private void button1_Click(object sender, System.EventArgs e)
{
st="123";
}
//这是窗体1public From2()
{
InitializeComponent();}
private void button1_Click(object sender, System.EventArgs e)
{
From1 f=new From1();
f.st.Equals("123");
MessageBox.Show("窗体1的值");
}
//这是窗体2我不知道怎么弄啊 ~ 我试了好次几次都找不f.st.Equals("123");找不到123值
我在From1 直接写 public string st="123"; 它就找的到哦
高手帮忙急用~~~~~~
public From1()
{
InitializeComponent();}
private void button1_Click(object sender, System.EventArgs e)
{
st="123";
}
//这是窗体1public From2()
{
InitializeComponent();}
private void button1_Click(object sender, System.EventArgs e)
{
From1 f=new From1();
f.st.Equals("123");
MessageBox.Show("窗体1的值");
}
//这是窗体2我不知道怎么弄啊 ~ 我试了好次几次都找不f.st.Equals("123");找不到123值
我在From1 直接写 public string st="123"; 它就找的到哦
高手帮忙急用~~~~~~
解决方案 »
- 向高手请教在C#中访问SQL数据库
- winform 自定义控件textbox无法输入小数点
- 请问如何把程序右上角的关闭按钮,最小化按钮,最大话按钮取掉?
- 急急急!求C#入门经典 习题答案和源码
- 质疑vs2005编译出一空窗体程序,运行后察看任务管理器,竟然占用30M内存左右.最小化又恢复只占2M多,请问这是怎么回事?
- 软件开发.NET/C#入门(请指教)
- 急需解决 ReportingServices2005 出问题在CS程序中无法访问报表 异常:System.Net.WebException: The request failed with HTTP status 401: Access Denied
- 请教:数字截取问题
- C#发送传真程序未报错,但是传真机也未打印
- System.ComponentModel.Win32Exception: 系统找不到指定的文件。
- 那位老大能提供一个完整的DataGrid的显示主从表的例子!
- xsd转换成xml文件的问题,简单问题,高分相送
From2 fr=new From2(st);
fr.ShowDialog();
窗体2:
private string st1;
public From2(string st)
{
st1=st;
InitializeComponent();}
后面就可以用st1了,就把st传到了form2
static public string stl;
Form1:
public static string st;Form2:
Form1.st.equals("123")
当然就没有st的值了
在Form1:
public string mstr;
button1_Click(...)
{
mstr="我是父窗口中的字符串";
}
button2_Click(..)
{
Form2 sw=new Form2();
sw.main=this;
sw.Show();
}
button3_Click(...)//显示一下该字符串,以确定是否在子窗口button1的按下后改变了?
{
if(mstr!=null)
MessageBox.Show(mstr);
}
------------------------------------------------
在Form2:
public Form1 main;
button1_Click(..)
{
if(main.mstr!=null)
MessageBox.Show(main.mstr);
main.mstr="我被子窗口改了";
}