• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Form refuses to center

We have large program with at least 30 forms that except one display properly in the center of the screen when asked.  This one, and only one (naturally one most used) is errant.  It always jumps up to the top of the screen.  Most annoying.  Have tried all manner of options in properties, nothing seems to work.  There must be something different in this one, but can't find any difference between this and others. It works OK when maximized.  

Thanks in advance?
0
forrestx
Asked:
forrestx
1 Solution
 
Arthur_WoodCommented:
I assume that you have the StartUpPosition property of the "errant" for set to 2-CenterScreen ?

Is ther any code in the Form_Load event that would change the StartUp position?

Arthur Wood

0
 
PaulHewsCommented:
If as arthur suggests the Startup Position property is set to Center Screen, then it is being changed in the code somewhere...

Do a search in the entire project code for:

<name of form>.Move
and
<name of form>.Top

Also look in the form code for:
Me.Move
Me.Top


This might find where it is being moved.  If that doesn't find it (it might be referenced by a different variable) Go to the debug menu, add a watch, for expression, enter <name of form>.Top and check the option that says break when value changes.  Change the procedure to (All Procedures) and change the module to (All Modules). Then run your program and it will break whenever the value changes.
0
 
dhammond-kuCommented:
Hi forrestx,

Here is code that you should work to center the form on the screen, no matter what is happening with the CenterScreen property. You could either put it in the Form_Load procedure, or after the code in which the form is loaded:

FormName.Left = (Screen.Width - FormName.Width) / 2
FormName.Top = (Screen.Height - FormName.Height) / 2
FormName.Show

Hope that helps...

Danny Hammond
hammond@ku.edu
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
PaulHewsCommented:
dhammond-ku, I notice you are new here.

The etiquette in this topic area (as in most topic areas here at EE is to comment rather than answer.

Also, if there is code in Form_Resize that sets the top and left properties of the form, your code is going to be as useless as the StartUpPosition property.
0
 
dhammond-kuCommented:
Thanks for the tip about comments...I hadn't actually realized that there was a difference at first (It was VERY late at night when I signed up).

Danny
hammond@ku.edu
0
 
alaplumeCommented:
Is the form embedded in some other object (ocx maybe). That could cause problems when centering.
0
 
kodiakbearCommented:
Dear dhammond-ku
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Thanks !

kodiakbear
Experts Exchange Moderator
0
 
DanRollinsCommented:
Hi forrestx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept PaulHews's comment(s) as an answer.

forrestx, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now