![]() |
![]() | #1 |
Академик Join Date: 01 2002 Location: Shambala Age: 39
Posts: 7,015
Downloads: 11 Uploads: 0
Reputation: 267 | 5 | ![]()
Zoxovurd uxexs cakvav mi ban sxal em anum ha errora tali uremn xndirs dasakana ka MDI application. MainForm u mek el ChildForm uzum em ChildForm pakveluc xabar ani MaiNForm in vor pakvela Dra hamar delegat,event u argument er em haytararum ChildForm i class um senc publicclassUserRequestEventArgs : EventArgs { publicstring Message; public UserRequestEventArgs(string s) { Message = s; } } publicdelegatevoidUserRequest(object sender, UserRequestEventArgs e); publiceventEventHandler<UserRequestEventArgs> OnUserRequest; heto ed nuyn CHildForm i classum grum em vor pakveluc ... if (OnUserRequest != null) { UserRequestEventArgs mtcea = newUserRequestEventArgs("Message from OnOneSecond"); erRequest(sender, mtcea); } this.Close(); ... u mek el MAIN FORM i classum frm.OnUserRequest += newfrmMain.UserRequest(); u mek el asum em ed nuyn MAINFROM um vor privatevoid UserReq(object sender, UserRequestEventArgs e) { MessageBox.Show( e.Message.ToString()); } vortex frm ed childform i arden stexcac instance a, isk frmMain el MAIN FORMNA inchna ste sxal zoxovurd??? compile chi linum xndrum em es xndir asxhatacneq motnerd henc stacvi (henc CHILD formen pakes main forum MessageBox.SHow lini) aseq grem tesnem. |
![]() |
![]() | #3 |
Creator Join Date: 06 2002 Location: Sliema, Malta Age: 40
Posts: 28
Downloads: 1 Uploads: 0
Reputation: 12 | 0 | ![]()
I think in MainForm you should add your event hadler in this way: frm.OnUserRequest += new UserRequest(frmMain.UserReq); |
![]() |
![]() | #4 | |
Грустно... Join Date: 08 2002 Location: Там, где всегда идут дожди Age: 36
Posts: 21,717
Downloads: 2 Uploads: 0
Reputation: 250 | 8 | ![]() Quote:
Но проблема тут в дизайне и не совсем ясно, как будешь потом отписываться от евента, ведь дочерняя форма-то уже может быть диспознутой. Так можно и мемори ликов нахвататься. | |
![]() |
![]() | #7 |
Академик Join Date: 06 2004 Location: Yerevan
Posts: 9,326
Downloads: 3 Uploads: 0
Reputation: 680 | 5 | ![]() Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class ChildForm : Form { public ChildForm() { InitializeComponent(); } } } Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class MDIForm : Form { ChildForm chilForm = new ChildForm(); public MDIForm() { InitializeComponent(); chilForm.Show(this); chilForm.FormClosed += new FormClosedEventHandler(OnFormClosed); } private void OnFormClosed(object sender, FormClosedEventArgs e) { MessageBox.Show(e.CloseReason.ToString()); } } } |
![]() |
Sponsored Links |