我想从弹出窗体中接收返回值。 在弹出窗体上有一个gridControl,需要在父窗体gridControl中插入值。
我把它称为弹出窗口:
private void label14_Click(object sender, EventArgs e)
{
frmSelectInvoice selectInvoice = new frmSelectInvoice();
selectInvoice.ShowDialog();
}
这是弹出式表格来源:
public partial class frmSelectInvoice : DevExpress.XtraEditors.XtraForm
{
public ValinorEntities valinor;
public BindingSource src;
public frmSelectInvoice()
{
InitializeComponent();
using (this.valinor = new ValinorEntities())
{
this.valinor = new ValinorEntities();
this.src = new BindingSource(valinor.invoices_head, null);
gridControl1.DataSource = src;
src.DataSource = valinor.invoices_head;
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
弹出窗体中的返回值应该是什么?
答案 0 :(得分:0)
使用静态类;
public static class MyClass
{
public static object myValue;
}
private void label14_Click(object sender, EventArgs e)
{
frmSelectInvoice selectInvoice = new frmSelectInvoice();
selectInvoice.ShowDialog();
//Get value before close
object value = MyClass.myValue;
}
public partial class frmSelectInvoice : DevExpress.XtraEditors.XtraForm
{
public ValinorEntities valinor;
public BindingSource src;
public frmSelectInvoice()
{
InitializeComponent();
using (this.valinor = new ValinorEntities())
{
this.valinor = new ValinorEntities();
this.src = new BindingSource(valinor.invoices_head, null);
gridControl1.DataSource = src;
src.DataSource = valinor.invoices_head;
}
}
private void button1_Click(object sender, EventArgs e)
{
//Set value after close
MyClass.myValue = "value";
this.Close();
}
}