>public interface IRefresh >{ > void RefreshData(); >} >>
>public class Form1 : Form, IRefresh >{ > public void MethodToCallForm2() > { > OtherForm Form2 = new OtherForm(this); > Form2.ShowDialog(); > } > > // IRefresh interface method > public void Refresh() > { > // code here for refreshing your data > } >} >>
>public class OtherForm : Form >{ > #region Declarations > > protected IRefresh CallingControl = null; > > #endregion > > #region Constructors > > public OtherForm(IRefresh callingControl) > { > this.CallingControl = CallingControl; > InitializeComponent(); > } > > public OtherForm() > { > InitializeComponent(); > } > > #endregion > > #region Events > > /// or whatever event you want to use to signify you're done. > private void cmdOK_Click(object sender, System.EventArgs e) > { > // If this dialog form was called by a class that implemented IRefresh, > // then call call the Interface method. > if (this.CallingControl != null) > { > this.CallingControl.Refresh(); > } > } > > #endregion >} >>