110,537
社区成员
发帖
与我相关
我的任务
分享
Public Class Model
{
private string _value;// 以string 为例
public string FormData
{
set{_value=value;}
get{return _value;}
}
}
string a=treeView1.SelectedNode.Text
public delegate void CustomEventHandler(IList<Pro_producePlanBillDetail> returnListProPlanDetail);
public event CustomEventHandler CustomEvent;/在窗体A定义委托和事件
private void btnOK_Click(object sender, EventArgs e)
{
#region 确定
IList<Pro_producePlanBillDetail> ListCheckedPlanDetail = new List<Pro_producePlanBillDetail>();
for (int i = 0; i < ListProPlanDetail.Count; i++)
{
if (Convert.ToBoolean(this.dgvDetail.Rows[i].Cells["Column1"].Value))
{
ListCheckedPlanDetail.Add(ListProPlanDetail[i]);
}
}
if (ListCheckedPlanDetail.Count > 0)
{
if (CustomEvent != null)
{
CustomEvent(ListCheckedPlanDetail);//在窗体A发布事件
}
}
this.Close();
#endregion
}
private void 选择单据ToolStripMenuItem_Click(object sender, EventArgs e)//在窗体B调用窗体A并注册事件
{
if (this.cboProName.Tag == null)
{
MessageBox.Show("请选择产品","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
ProProduct pro=(ProProduct)this.cboProName.Tag;
frmChooseProPlan frmChoosePlan = new frmChooseProPlan(pro);
frmChoosePlan.CustomEvent += new frmChooseProPlan.CustomEventHandler(frmChoosePlan_CustomEvent);
frmChoosePlan.ShowDialog();
}
private void frmChoosePlan_CustomEvent(IList<Pro_producePlanBillDetail> returnListProPlanDetail)//自定义的事件处理方法
{
//接收到从A传过来的值后进行相应操作
}