none
How to change a button colour

    Question

  • Hi,

    I have recently returned to creating some (simple!) apps. I used to use Visual Basic 2010, but have now downloaded Visual Studio 2017 and now cannot work out how to change the colour of a button when another button is clicked. it used to be

    button1.backcolor = color.red

    But there is no longer this code. What would be the equivalent in the new visual studio?

    Thanks in advance.

    Joel

    Friday, April 28, 2017 9:43 AM

Answers

  • Don't you get Intellisense like shown below? There are no changes in VS2017 that would prohibit you from using this.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by griffij10 Tuesday, May 2, 2017 4:13 PM
    Friday, April 28, 2017 9:55 AM
    Moderator

All replies

  • Don't you get Intellisense like shown below? There are no changes in VS2017 that would prohibit you from using this.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by griffij10 Tuesday, May 2, 2017 4:13 PM
    Friday, April 28, 2017 9:55 AM
    Moderator
  • Hi,

    I have recently returned to creating some (simple!) apps. I used to use Visual Basic 2010, but have now downloaded Visual Studio 2017 and now cannot work out how to change the colour of a button when another button is clicked. it used to be

    button1.backcolor = color.red

    But there is no longer this code. What would be the equivalent in the new visual studio?

    Thanks in advance.

    Joel

    No that alone does not change the backcolor if another button is clicked. 

    Therefore show your complete code in the method (function or sub) you use. 

    By the way, it this is not changed in visual studio for Windows Forms or WPF or any other technology I know. 


    Success
    Cor

    Friday, April 28, 2017 12:28 PM
  • Hi,

    Your code should work as you expect, if it would be executed.

    Add a code just below it, MessageBox.Show("color red").

    If the messaga won't appear, you will find your code isn' t executed.


    • Edited by Ashidacchi Friday, April 28, 2017 12:34 PM
    Friday, April 28, 2017 12:32 PM
  • Hi,

    I have recently returned to creating some (simple!) apps. I used to use Visual Basic 2010, but have now downloaded Visual Studio 2017 and now cannot work out how to change the colour of a button when another button is clicked. it used to be

    button1.backcolor = color.red

    But there is no longer this code. What would be the equivalent in the new visual studio?

    Thanks in advance.

    Joel

    Hi,

    is the eventhandler in which you set the buttons backcolor executed (is the event "connected" to that handler, eg by a Handles statement)?

    Regards,

      Thorsten

    Friday, April 28, 2017 2:03 PM
  • Hi, thanks for your reply. 

    I managed to get it working, it was the bit after the = I was having trouble with.

    Button1.backcolor = drawing.backcolor.red

    Thanks

    Friday, April 28, 2017 3:56 PM
  • Yea this is strange but maybe you did set the "import" in version 2010 in another way. 

    Look at this and set it in that way which is more commenly done in VB (Thorsten I know that it is in C# different and can be done in VB likewise)



    Success
    Cor

    Friday, April 28, 2017 4:12 PM
  • Hi griffij10,

    Please refer to close your thread by marking helpful post as answer, it is very beneficial to the other communities who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry Bu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 2, 2017 2:50 AM
    Moderator