I don't know why do you want to call it but take a look at this sample:
InvokeKeyEventHandler(button1, "KeyDown", Keys.A);
....
private void InvokeKeyEventHandler(Control c, string eventName, Keys k)
{
FieldInfo fi = null;
Type typeControl = c.GetType();
// find correct FieldInfo for passed eventName
while (typeControl != typeof(System.Object))
{
fi = typeControl.GetField(eventName, BindingFlags.NonPublic |
BindingFlags.Instance);
if (fi != null) break;
typeControl = typeControl.BaseType;
}
if (fi == null) throw new ArgumentException("Impossible to find: " +
eventName);
// invokes each handler in the invocation list
foreach(KeyEventHandler keh in (fi.GetValue(c) as
MulticastDelegate).GetInvocationList())
{
keh.Invoke(c, new KeyEventArgs(k));
}
}
However, I'd recommend you to use OpenNETCF.Windows.Forms.SendKeys which
works like System.Windows.Forms.SendKeys:
http://msdn2.microsoft.com/library/k3w7761b.aspx
--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com
I ttry this:
Button MyButton...
MyButton.KeyDown();
but I get this
"The event 'System.Windows.Forms.Control.KeyDown' can only appear on the
left hand side of += or -="
Thanks
Frankie