c#委托----我的一点笔记

时间:2023-03-09 01:59:43
c#委托----我的一点笔记
 public partial class ucBloodLabs
{
public delegate void ShowBloodEvent();
public ShowBloodEvent ShowBloodData;
}
public partial class ucDiabeticLab
{
public delegate void ShowCurrentDataEvent();
public ShowCurrentDataEvent ShowCurrentData;
}
   public partial class frmLaboratory {

 ucDiabeticLab.ShowCurrentData += new ucDiabeticLab.ShowCurrentDataEvent(showBloodLabData);
private void showBloodLabData()
{
if (ucBloodTabs == null)
{ ucBloodTabs = new ucBloodLabs(str_PatientId, str_PatientSN);
this.pan_Left.Controls.Add(ucBloodTabs);
ucBloodTabs.Dock = DockStyle.Fill;
ucBloodTabs.ShowBloodData += new Control.ucBloodLabs.ShowBloodDataEvent(showBloodData);
}
this.ucDiabeticLab.Visible = false;
if (ucBloodTabs != null)
{
this.ucBloodTabs.Visible = true;
this.ucBloodTabs.BringToFront();
}
this.ucBloodTabs.PatientId = str_PatientId;
this.ucBloodTabs.VisitId = str_PatientSN;
this.ucBloodTabs.InitPage();
if (frm != null)
{
frm.Close();
frm = null;
} }
private void showBloodData()
{
Application.DoEvents();
this.ucDiabeticLab.Visible = true;
if (ucBloodTabs != null)
{
this.ucBloodTabs.Visible = false;
}
}
}