C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,101 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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(?);
}
}
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 })