Hello,
VS 2008
I have a parent and child form. The parent will open the child form and the user will click on a button. This will set a link label property in the parent form. I am just wondering if there is a more object oriented way of doing this. The code below is short and simple, but just interested to know if there is some better and more reusable if I need to make any changes.
My code in the parent form.
Code in the child formCode://Display all the missed calls private void lnkMissedCalls_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { MissedCalls frmMissedCalls = new MissedCalls(); frmMissedCalls.ResetMissedCalls(new EventHandler(this.OnResetAttempted)); frmMissedCalls.Show(); } //Listen for when the clear list button is clicked in the child form and reset the label public void OnResetAttempted(object sender, System.EventArgs e) { this.lnkMissedCalls.Visible = false; }
Many thanks for any adviceCode://Create an event that the main form can listen to. Reset the label in the parent //form when the button is clicked in the child form. public void ResetMissedCalls(EventHandler _eventHandler) { this.btnClearCallList.Click += _eventHandler; }


Reply With Quote
