private void generalPractitionersToolStripMenuItem_Click(object sender, EventArgs e) { //Instance of frmGPList frmGPList GPListForm = new frmGPList(); //make its parent of this parent GPListForm.MdiParent = this; //display the form GPListForm.Show(); }
private void btnGPLookup_Click(object sender, EventArgs e) { //creat an instance of frmGPList frmGPList GPLookup = new frmGPList(); //make the MDI parent of this form the MDI parent of GPLookup GPLookup.MdiParent = this.MdiParent; //Open the form GPLookup.Show(); }
private void btnSelectGPFromList_Click(object sender, EventArgs e) { //create an instance of the frmGPsList called GPListForm frmGPList GPListForm = new frmGPList(); //make the MDI parent of the form be this MDI parent form GPListForm.MdiParent = this.MdiParent; //(Note:concept of delegates (an event handler is a delegate) means we can //pass the method getGPSelectedFromList to the GPListForm object. Because they both have the same signature //the getGPSelected method can call that method GPListForm.GPSelectedFromList += new EventHandler(getGPSelectedFromList); //display the GPListForm GPListForm.Show(); }
//this function handles the event from the GP List form. //It fetches the GP number and puts it in the GP No text box on this form private void getGPSelectedFromList(object sender, EventArgs e) { //When the Child GPs List form has a GP selected this will get the GP number. //Declare a string variable to store the GPNumberSelected string GPNumberSelected; //We need an instance of the frmGPList that will be used to send us the information we need frmGPList GPListChildForm = sender as frmGPList; //if GPListChildForm is not empty i.e. list is populated if (GPListChildForm != null) { //get the GP number from the GP list using the getGPNumber() function GPNumberSelected = GPListChildForm.getGPNumber(); //put the Selected GP number in the textbox on this form this.txtGPNo.Text = GPNumberSelected; } }