954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to call Method/Procedure of Child form from MdI parent in C#

i want that when i click NewToolstripbutton it run active child form newbutton procedure

Note: newbutton is a userdefine Procedure.

Help if any body known

Ammad Iqbal

ammadiqbal
Newbie Poster
4 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

I dont think its such a hard Question. I am New in C#.
IN Vb i do this in that fashion

Dim FrmChild As Object
FrmChild = Me.ActiveMdiChild
FrmChild.NewButton()

And its work But in C# it generate error on NewButton()

ammadiqbal
Newbie Poster
4 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

You need to ensure that the MDI Child has a method called NewButton and that the method is declared as Public.

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 
You need to ensure that the MDI Child has a method called NewButton and that the method is declared as Public.

NewButton is a public Method. but i resoled it like this:

try
            {
                FormCollection fc = Application.OpenForms;
                foreach (Form f in fc)
                {
                    if (f.Name == "Frm_Supplier")
                    {
                        ((Frm_Supplier)(f)).NewButton();
                    }
                }
            }
            catch
            {
                Exception Ex = new Exception();
                MessageBox.Show(Ex.Message);
            }
ammadiqbal
Newbie Poster
4 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: