c# - Handling an array of buttons -


I am creating a simple game where a melody is played, and it is considered to highlight the notes with the button.

Then the user has to push the button, and the button is highlighted again during each click. I want to keep all GUI buttons on graphically.

  1. Can I add highlights to buttons in the GUI? I know that I can probably create a new square which comes out of some button class and creates a button in the code, but I like to graphic it.

  2. What is the fastest way to handle button output? I know that I can paste it into code for each button, such as

      private zeros button_windex (object sender, event aRGS) {checkIfThis notes correct (); HighLightThisButton (); SetHighLightOffForAllOtherButtons (); However, I think it is necessary to collect all the buttons in some types of container classes and make a function such as  
      class button, arehendler / / constructor etc. * / private zeros some buttons (object sender) {/ * Check that which button was clicked and stuff accordingly * /}}   

    Although I do not know how to suggest it?

    You can change the button color to create the highlight effect, but if it is a game you do Use images / graphics for buttons, and when they are clicked, swap them on other graphics.

    When you double-click on a button / graphic / control, by default it creates a method and links it to the click action for you. Instead, click on each control, then small electric icon, and click action, choose the same method for all of them.

    Then enter the object sender to get the original control in your method, for example:

      var clicked button = (button) Sender;   

    Where can (buttons) be (graphics) or whatever control buttons you use. Edit:

    If you need to reach a set of controls, you can either place a global list of names at the top of the form and loop through them:

      Public listing & lt; String & gt; Button list = new list & lt; String & gt; () {"button1", "button2"}; Zero some method () {foreach (name control in the button control) {This. Control [controlName]. Text = "test"; }}   

    or use a fixed name and number boundary:

      some method of zero () {for (int i = 1; i & lt; = 2; I ++) {this. Control ["Button" + i] Text = "test"; }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -