Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27512

Form Show/Hide issue question

$
0
0
I'm trying something that I haven't previously had to do: Keep a form in existence for the life of a program, though it will generally not be shown. The reason I'm doing this is that the form is pretty complex. Some of the setup takes a terrible amount of time, which means that the form can take 3-4 seconds to show itself. I really hate to have people wait that long watching a cursor spin. Therefore, I calculated out the time and found that about 75% of the total time was involved with control creation that could be paid one time if I just created the form once on app startup and showed/hid the form as needed.

The control creation is so costly because I'm making a grid of usercontrols. The grid has to size dynamically in response to the user changing the screen size. Adding and deleting controls in such a design is utterly painful, so I decided to create all the control I would need at one time (based on the maximum size the grid can attain, which is based on the screen size minus the unusable area), and only show the ones that were needed. This makes changes to the operating form very fast, but I pay the whole cost of creating the maximum possible controls up front.

The next step was to curtail the cost of form creation by creating one form at app startup (which is already slow, but so many apps are at startup that people are used to that) and showing/hiding it as needed. However, the data loaded into the grid is determined by various factors, so I'm using the VisibleChanged event to load the grid (the other 25% of startup cost). This appears to be working.

My question is: Is there a better event to be using other than VisibleChanged for a form that will have to exist for the life of the program, will remain not visible for most of the program, and will toggle visibility as needed?

Viewing all articles
Browse latest Browse all 27512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>