question

StephenPrestwich-6616 avatar image
0 Votes"
StephenPrestwich-6616 asked StephenPrestwich-6616 commented

method.invoke question

I have a master form with a bunch of sub forms. Each sub form has the same method name "RefreshData". I need help finishing the invoke method to execute the refreshdata method on the subform from the master form. My code is below.


button click event on master form. ClsCommon.NewRfrmCurr holds the current sub form object.

var type = ClsCommon.NewRfrmCurr.GetType();

                     MethodInfo[] methods = type.GetMethods();
                     foreach (MethodInfo method in methods)
                     {
                         if (method.Name == "RefreshData")
                         {
                             method.Invoke(?);
                         }
                     }
dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Paul-5034 avatar image
0 Votes"
Paul-5034 answered StephenPrestwich-6616 commented

It should just be:

method.Invoke(ClsCommon.NewRfrmCurr, new object[] {  })


Does RefreshData accept arguments? If so you'll need to add them into that object array:

method.Invoke(ClsCommon.NewRfrmCurr, new object[] { arg1, arg2, arg3 })
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, that worked, No arguments.

0 Votes 0 ·