Hello,
I always set the modifiers on my form to private,I don't like internal nor public.
Till now I used to Invoke like this:
public string Addtext
{
if(InvokeRequired)
{
Invoke((MethodInvoker)delegate
{
textbox.text = value;
});
}
else
textbox.text = value;
}
But adding such property for every member on my form is just not Object Orientated at all.
I want to create a function that will Invoke the parameter(action).I tried my best,but I failed - it requires the form members to be public or internal :(
public void PerformActionOnForm(Action<FormMain> action)
{
var form = Form.ActiveForm as FormMain;
object s = action.Clone();
if (form != null)
{
form.PerformAction(action);
}
}
public void PerformAction(Action<FormMain> action)
{
if (InvokeRequired)
Invoke(action, this);
else
action(this);
}
two problems in my code:
It requires the property I'd like to change to be != private :(
Doesn't work if the form is not on focus.