Windows Develop Bookmark and Share   
 index > Windows Forms General > MDI question
 

MDI question

how can i make the mdi.Children raise a event on the mdi.Parent?!?!? to be more precise... i want to raise a event related with the dialogResult... cause u see my mdi children are edit dialogs... so... when the user press the "Confirm changes" i want to fire a event on the mdiParent... and if "cancel" is hit... do nothing... know what i mean?!?!
LeonardoIndex  Monday, September 14, 2009 8:04 PM
Your MDI child cannot be a dialog, the DialogResult property thus doesn't apply. Raising an event is otherwise not a problem. For example:

public partial class EditChildForm : Form {
public event EventHandler ApplyChanges;
public EditChildForm() {
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e) {
if (ApplyChanges != null) ApplyChanges(this, EventArgs.Empty);
this.Close();
}
}

Usable from the MDI parent like this:

private void btnOpenEditor_Click(object sender, EventArgs e) {
EditChildForm frm = new EditChildForm();
frm.ApplyChanges += new EventHandler(frm_ApplyChanges);
frm.MdiParent = this;
frm.Show();
}

void frm_ApplyChanges(object sender, EventArgs e) {
EditChildForm frm = sender as EditChildForm;
// Do something...

}


Hans Passant.
  • Unmarked As Answer byLeonardoIndex Tuesday, September 15, 2009 2:17 PM
  • Marked As Answer byLeonardoIndex Tuesday, September 15, 2009 1:39 PM
  •  
nobugz  Monday, September 14, 2009 9:14 PM
actually i have to create also a delegate...
LeonardoIndex  Tuesday, September 15, 2009 2:17 PM
Sure, why not.

Hans Passant.
nobugz  Tuesday, September 15, 2009 2:24 PM

You can use google to search for other answers

Custom Search

More Threads

• Run Framework 1.1 and 2.0 application at the same time on the same machine.
• Title bar Close button handler?
• Control Suspend/Resume Layouts alter control values...
• WorkingArea isn't correct on Windows Vista
• Input Message Box in C#?
• Using the Graphics class to draw a string on a panel control. I'm stumped!
• Desktop
• Data binding to a custom control?
• MDI causes customized WebBrowser to fail, InvalidVariant (C# 2008)
• How Can I bring the Menu list of Recently Opened file in Forms?