Windows Forms
-
if those methods are public, child form can siply keep reference to it's parent.. oh wait.. that should we be in
Owner
property of child form, if you display it withShowDialog( IWin32Window )
overload of that method. If they are not public, can you make thempublic
? ( orinternal
) David -
A parent form is a form which is a MdiContainer. A child form can call its parent using childfrom.MdiParent. ==== Lei Ming 2004 ===== ====================
-
Yes but the methods of the parent form are not shown using childform.MdiParent What if i'm not using an MDI container?
You need to cast it the concrete class. i.e. MyMainForm frm = Parent as MyMainForm; 60% of statistics are made up on the spot
-
You need to cast it the concrete class. i.e. MyMainForm frm = Parent as MyMainForm; 60% of statistics are made up on the spot
Still not getting it. This is my code: In the MainForm (GameForm)... BuyingForm f = new BuyingForm(new_item); //new instance of a "child" form GameForm gameForm = Parent as GameForm; f.Parent = gameForm; f.Show(); In the ChildForm (BuyingForm)... this.ParentForm.SomeMethod(); //the method is not listed
-
Still not getting it. This is my code: In the MainForm (GameForm)... BuyingForm f = new BuyingForm(new_item); //new instance of a "child" form GameForm gameForm = Parent as GameForm; f.Parent = gameForm; f.Show(); In the ChildForm (BuyingForm)... this.ParentForm.SomeMethod(); //the method is not listed
Setup a field on your BuyingForm that holds a Form:
public class BuyingForm : Form
Form myParent;
.
.
.
myParent.PublicMethodCall( parameters );When you create an instance of this form, just set this field before you show the form:
// GameForm code
BuyingForm f = new BuyingForm(new_item);
f.myParent = this;
f.Show();If you use the Parent property of the form to do this, you could have some very strange and unintended side effects. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Setup a field on your BuyingForm that holds a Form:
public class BuyingForm : Form
Form myParent;
.
.
.
myParent.PublicMethodCall( parameters );When you create an instance of this form, just set this field before you show the form:
// GameForm code
BuyingForm f = new BuyingForm(new_item);
f.myParent = this;
f.Show();If you use the Parent property of the form to do this, you could have some very strange and unintended side effects. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
If you look at my previous post, you don't have to worry about it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
If you look at my previous post, you don't have to worry about it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
If you look at my previous post, you don't have to worry about it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome