Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

On form load of main Form a file is checked for if the file exists and contains certain data then a 2nd FOrm is opened...

 

WHat I am needing to know is 2 things....

 

1. How do I make it so the Form2 is the one that has the focus and not Form1

 

2. Also, How do I make Form2 open dead center of Form1?

 

 

vbMarkO

Visual Basic 2008 Express Edition!
  • Leaders
Posted

For #2, you have two choices. One, set Form2's startup position property to CenterParent (via designer) and set the form's parent as the instance of Form1 (via code). Two, you can do the math out yourself, but positioning forms before they are shown has a tendency to work inconsistently at best and positioning them after they are shown looks unprofessional.

 

For #1, I haven't tested this. I'm just throwing it out there. You could explicitly show both forms (possibly in Form1's load event) and then set focus to Form2.

[sIGPIC]e[/sIGPIC]
Posted
I believe setting focus in the form load event will not work because the Activated event is triggered after the load event, and that will bring focus back to the main form. So based on this assumption, if you declare Form2 publicly, then initialise it only if you need to, in the Activated event of Form1 check if Form2 = null if not the set focus to it.You probably also need a boolean to check its the first call to activated so that it doesn't keeep showing Form2 everytime you activate Form1. This all sounds abit messy, theres probably a better solution, but I can't think of one.
Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...