像這樣的事情在ObservableForm是一個基類,包含了進一步的flexability的的ChangeEvent:
public class FormMain : Form
{
private ObServableForm childForm = null;
public FormMain() {
this.childForm = new ObservableFormConcreateA(this);
this.childForm.ChangeEvent += (sender, e) => Application.DoEvents();
}
public void Present() {
this.childForm.Show();
}
}
public class ObservableFormConcreateA ObServableForm
{
private Form workItemForm = null;
private delegate void FormChangedHandler(object source, EventArgs args);
//ToDo: this should go in the superclass
public event FormChangedHandler ChangeEvent;
public FormChild(ObServableFormworkItem) {
this.workItemForm = workItem;
}
public void OnUserActionHandler(object sender, EventArgs e) {
this.formItemForm.Property = this.txtBoxWhateverValue.Text;
if(ChangeEvent != null)
ChangeEvent(this, //create your args to specify which control/data changes);
}
}
這是你正在談論的WinForms? – 2011-02-03 15:08:45
[C#中兩個窗體之間的通信]的可能重複(http://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c)和許多其他許多人。 – 2011-02-03 15:17:51
http://stackoverflow.com/q/4373660/60761,http://stackoverflow.com/q/3034493/60761 – 2011-02-03 15:20:26