简体   繁体   中英

Passing parameters to button click methods within the SAME windows form

I'm currently programming Hangman in C# using windows form and I've got a fair way through it. I'm using an array to store the words that can be guessed - a bit limited I know, but I don't know much about databases. I use a random number generator to search through the array to select a word.

Is there a way to pass parameters to different methods within the SAME windows form?? So far, when I create a parameter inside a button click method the design form disappears and says I cant edit it. I have different methods set up which consist of button clicks, and I would need to send each method the selected word to check whether it had any of those specific letters in it. Any help appreciated!!!

You don't need to pass extra parameters to click handlers. Just add a private field to form which will contain selected word and every method in the form will have access to it.

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