Results 1 to 2 of 2

Thread: is setting a boolean the only way to detect if a button has been clicked?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    is setting a boolean the only way to detect if a button has been clicked?

    Hi all.

    I have written a calculator program, and when the mouse clicks on the equals button, the button sets a boolean varaible to true, and then that variable can be used later.

    But I am wondering if the button control has it's own property that can indicate if it has been pressed?

    Thanks in advance.

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: is setting a boolean the only way to detect if a button has been clicked?

    Event driven programming doesn't work that way, you never need to check a button to see if it was clicked or not, instead you handle it's click event so when it does get clicked it runs that code.

    For example, when the equals button is clicked you should complete the math operation (IE do the addition or subtraction, etc) & store that in the variable as well as show the result to the user. Then when they click another button if it's an operation (addition, subtraction, etc) you already have the result stored so it should be no different than if they clicked a number button first.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width