Startup Event on a VB.NET Form


B

Barry

Hi

I am working on conversion of a VB6 project to VB.NET (VS 2005), the project
has one main form with a Tab Controls and about seven Tabpages with many
controls on them.

1. Which event on the form receives focus first, i found that Load event
does not recieve focus first, hence the app crashes as some of the controls
are updated in code through their respective events.

2. I need to hide the form at the start to activate it from the Taskbar, but
that does not seem possible to hide the form Load event.

Tia
Barry
 
Ad

Advertisements

F

Family Tree Mike

Barry said:
Hi

I am working on conversion of a VB6 project to VB.NET (VS 2005), the
project has one main form with a Tab Controls and about seven Tabpages
with many controls on them.

1. Which event on the form receives focus first, i found that Load event
does not recieve focus first, hence the app crashes as some of the
controls are updated in code through their respective events.

2. I need to hide the form at the start to activate it from the Taskbar,
but that does not seem possible to hide the form Load event.

Tia
Barry

1. It sounds like your controls need to be more resilient to events that
occur as the form loads. Unfortunately we cannot help much until you tell
us what is going on in the code. For example, if you have a couple of text
boxes which hold numerical values, and a third that computes some value
based on those two values when either changes, then you need to confirm the
values are good. Textbox1 may be initialized before textbox2, and therefore
textbox1 raises a textchanged event.
2. Set the form's WindowState property to Minimized in the designer.
 
P

PvdG42

Barry said:
Hi

I am working on conversion of a VB6 project to VB.NET (VS 2005), the
project has one main form with a Tab Controls and about seven Tabpages
with many controls on them.

1. Which event on the form receives focus first, i found that Load event
does not recieve focus first, hence the app crashes as some of the
controls are updated in code through their respective events.

2. I need to hide the form at the start to activate it from the Taskbar,
but that does not seem possible to hide the form Load event.

Tia
Barry
You can try this approach, which works for me here in somewhat simpler
circumstances. Set the Visible property of your form to False in the Load
event procedure, then do all your form and control property settings in the
Form_Activated event procedure, then (still in Activated) set the Visible
property to True.

As you are discovering, event order and timing is a bit different in .NET.
 
B

Barry

Your last line gave me some clues.

Indeed there are 2 Timer controls which maybe causing these problems.

Remember this app is converted from VB6 to VB.NET (VS 2005)
 
Ad

Advertisements

B

Barry

The issue of other events firing before form Load, was solved by disabling
the Timer controls at design-time.

As for the issue of hiding the form was concerned neither Hide() nor Visible
= false works
What does work is setting the Opacity to 0 = hide 1 = Show
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top