I have a problem with changing the color of a button (in vb.net). I have searched the web and plenty of people are willing to tell me HOW TO change the color but my problem is - it doesn't. I say it doesn't, it does when it has finished the rest of the code in the Sub. Can anyone furnish me with an explanation please as to why it doesn't happen when I ask? I'm using Visual Studio 2008
preguntado el 10 de marzo de 12 a las 08:03
After changing the colour call Application.DoEvents()
This gives the GUI a chance to update.
Application.DoEvents will work, but it's the wrong solution for this.
The right solution has to do with the reason you don't want to wait for the end of the sub: you have some long running code in your method, and the method run in direct response to a UI event. In this situation, the Derecho La solución es usar un FondoTrabajador component to execute the long-running code, so the method will complete right away and the button can change color when it's supposed to.