sammi taylor

sammi taylor

  • NA
  • 19
  • 0

Pass ID from usercontrol1 to usercontrol2

Apr 21 2015 7:14 PM
I have 2 usercontrols in 1 parent form. I created event handler in UserControl1, added it to the ParentForm. From there, I need to pass id to Usercontrol2 to save it. 

UserControl1=MainCaseUserControl
Div
//Create delegate for my event  public delegate void CaseUpdatedEventHander(object sender, CaseUpdatedEventArgs e);  //add an event of the delegate type  public event CaseUpdatedEventHander CaseUpdated;  protected void OnCaseUpdated(int? ID)  {  CaseUpdatedEventArgs e = new CaseUpdatedEventArgs(ID);  if (CaseUpdated != null) CaseUpdated(this, e);  }


Div
 //MainUserControl

public CaseProfileBL CaseInvestigation { getset; }  private void CaseProfileForm_Load(object sender, EventArgs e)  {  mainCaseUserControl.InitUserControl();  mainCaseUserControl.CaseUpdated += new WindowsForm.UserControlTabs.MainCaseUserControl.CaseUpdatedEventHander( mainCaseUserControl_CaseUpdated);
 }
void mainCaseUserControl_CaseUpdated(object sender, CaseUpdatedEventArgs e)
 {  SetTabPages(e.ID.Value);  }
 private void SetTabPages()  {  if (CaseInvestigation.ID == null) { return; }
 this.tabControl1.Controls.Add(this.tabPageCaseProfile);


From the ParentForm, how do I pass the ID or value to UserControl2? And how do I retrieve the ID or value from my usercontrol to the form? I have to have an existing ID to save the data in UserControl2. Thank you