// 1.定义委托
public delegate void PassMsgToParentDelegate(string msg);// 2.定义委托变量
public PassMsgToParentDelegate passMsg;// 3.调用委托变量,传入参数passMsg("DefectUI");
子窗体
using ClassLibrary1.Forms.DelegateForm;
using ReaLTaiizor.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClassLibrary1.Forms
{// 1.定义委托
public delegate void PassMsgToParentDelegate(string msg);
public partial class FrmWorkFlowIsOver : MaterialForm
{// 2.定义委托变量
public PassMsgToParentDelegate passMsg;
public FrmWorkFlowIsOver(){InitializeComponent();}/// <summary>/// 流程结束/// </summary>/// <param name="sender"></param>/// <param name="e"></param>
private void btnYes_Click(object sender, EventArgs e){// 返回到OK NG界面// 3.调用委托变量,传入参数passMsg("OKNGUI");
this.Close();}/// <summary>/// 不结束/// </summary>/// <param name="sender"></param>/// <param name="e"></param>
private void btnNo_Click(object sender, EventArgs e){// 返回缺陷选择界面// 3.调用委托变量,传入参数passMsg("DefectUI");
this.Close();}}}