简体   繁体   中英

Visual C# How do you simulate click a button?

Is there any way to run a button's event handler from code?

I tried

btn.click(); btn.mousedown();

I tried calling the event handler but I didn't know what parameter goes to RoutedEventArgs e

you can directly call the button using btn.click(); and btn.mousedown(); and pass a new EventArgs( ) RoutedEventArgs.

Like

btn.click(btn,new EventArgs());

You can also call

btn.PerformClick();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM