473,382 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

VB.NET Windows App: Hiding Controls During Processing

Frinavale
9,735 Expert Mod 8TB
This question may seem a bit newbie-ish but I'm new to desktop applications...please bear with me.

I have a function that populates a ComboBox with a bunch of names.
To populate it I have to make a function call to an external class library (which is poorly designed) many many times (512 to be exact)....you can see that this will take a while.

After populating the ComboBox I initialize a user control which displays details about the first selected item.

Since it takes a couple of seconds to populate the ComboBox before the user control can be loaded I created a function that hides the user control (and any other controls that aren't available until everything's loaded) and display a "loading" message.

Expand|Select|Wrap|Line Numbers
  1.   Private Sub Updating()
  2.         'Centering the message
  3.         Dim x As Integer = theGroupBoxHoldingEveryThingWidth / 2 - UpdatingMessage.Width / 2
  4.         Dim y As Integer = theGroupBoxHoldingEveryThingWidth .Height / 2 - UpdatingMessage.Height / 2
  5.         UpdatingMessage.Location = New Point(x, y)
  6.  
  7.         'Hiding the controls and displaying the message
  8.         thePanelHoldingTheControls.Hide()
  9.         UpdatingMessage.Show()
  10.     End Sub
  11.  
I created a function that displays the content and hides the message:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub UpdatingFinished()
  2.         'Hiding the message and displaying the controls 
  3.         thePanelHoldingTheControls.Show()
  4.         UpdatingMessage.Hide()
  5.     End Sub
  6.  
The problem is that the controls are not hidden and the message is not shown while the processing is going on.

Originally I was using the Visible property to display updating message and hide the controls but since this didn't work I changed it to the Show() and Hide() methods.

I've stepped through the application and expected the content to be hidden as soon as the Hide() method was executed but this is not the case.

Does anyone know why this is happening?

Thanks for your time,

-Frinny
Oct 30 '08 #1
2 2812
Plater
7,872 Expert 4TB
Be sure to call the .Update() function on any gui object that you changed.

Whats roughly happening is:
You set the controls hidden, but before it has time to process the windows message for it, your program gets busy gathering values. When it stops being busy, it will process the messages, but since right after the "hide" message is probably a "show" message, you don't see a change.

What the Update() call does, is force the program to process the windows messages for that control(and child controls too I think), if you wanted it to process all windows messages in the queue, you would use Application.DoEvents()
Oct 30 '08 #2
Frinavale
9,735 Expert Mod 8TB
Be sure to call the .Update() function on any gui object that you changed.

Whats roughly happening is:
You set the controls hidden, but before it has time to process the windows message for it, your program gets busy gathering values. When it stops being busy, it will process the messages, but since right after the "hide" message is probably a "show" message, you don't see a change.

What the Update() call does, is force the program to process the windows messages for that control(and child controls too I think), if you wanted it to process all windows messages in the queue, you would use Application.DoEvents()
Thanks Plater!

The Control.Update method executes any pending requests for "painting". Since everything was within the the group box (theGroupBoxHoldingEveryThing) I only had to call the Update method on that group box.

:) This is going to fix a bunch of problems I was having with my other controls :)

-Frinny
Oct 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
0
by: dag | last post by:
Hi! I would like to do an overlap window, over my main window (of my application), with a Progress Bar. Exactly when I push a button of my application I want show a window, with a Progress bar,...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
7
by: Pavils Jurjans | last post by:
Hello, I wanted to get some light in the subject. As I develop ASP.NET applications, it's necessary to understand how exactly the server- communication happens. It seems like initially...
4
by: hzgt9b | last post by:
Using VB .NET 2003, I have a windows application that performs a series of file actions (copy, move, delete) but the actions are completing before the window is painted on the screen... how can I...
22
by: Jordan S. | last post by:
SQL Server will be used as the back-end database to a non trivial client application. In question is the choice of client application: I need to be able to speak intelligently about when one...
6
by: WhiteWizard | last post by:
I have been chasing what should be a simple problem for a day or two now. I have done the google thing, but all the problems listed (at least so far) have been problems with web applications. ...
3
by: mattgcon | last post by:
I was curiuos if anyone knew of a way to allow drag and drop functionality on the actual controls themselves during runtime within a Windows Application. I want to allow the user to customize a...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.