【发布时间】:2017-03-05 22:58:05
【问题描述】:
首先,我的英语不好,对不起。
我想要 textbox(在 Form2.cs 中)文本来显示 MainForm.cs
当我应用以下代码时,显示空白消息。
MainForm.cs
private void btnFilitre_ItemClick(object sender,DevExpress.XtraBars.ItemClickEventArgs e)
{
...
Form2 f2 = new Form2();
f2.Show();
}
private void workingFunction()
{
CommClass com = new CommClass();
MessageBox.Show(comm.Sorgu );
}
Form2.cs
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
CommClass comm = new CommClass();
comm.Sorgu = textBox1.Text;
f1.workingFunction();
Hide();
}
CommClass.cs
public string Sorgu { get; set; }
有什么问题?
【问题讨论】:
-
您正在每个地方实例化一个新的 CommClass 实例。 workingFunction 没有使用您在 button1_click 中声明的同一个 CommClass
标签: c# string properties prop