I'm designing a GUI and I have a label which I use effectively as a 'please wait' message after I invoke an action that tends to take a while. The label's text is static, I have set it in the properties in VS2010 for the label control.
When I hit that action on the form, I .Show() the control which is normally hidden until the time consuming process completes, then .Hide() it. When it hits the .Show() the label pops up (I know this because I have the BorderStyle set to Fixed3D so I see the border of the label show up) but there is no text in it whatsoever. I have tried setting the label to autosize and not to no avail, my text is set to black on gray, so no invisible ink, everything is visible, font is set. Code executes as I want it to throughout, theres just no text in the label. I'm at a loss.
Any ideas?
If the time consuming process is occurring on the same thread, then it could be a refresh/redraw issue (where the processor is too busy to handle UI requests). Try either refreshing the window before starting the long running process or, more appropriately, putting the time consuming process in a BackgroundWorker.
If the time-consuming process is not executing in a background thread, then your UI isn't updating because no message processing is taking place. Controls redraw themselves in WM_Paint messages.
Try calling Refresh on the control or on its window-handle parent (the form) after changing its state, before diving into the long process.
Or, move the long-running process into a background thread (see .NET 4.0 Task) to free up the UI thread.
Maybe I'm missing something, but why don't you just set label.Visible
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With