Link to home
Start Free TrialLog in
Avatar of forrestx
forrestx

asked on

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?
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

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

ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dhammond-ku
dhammond-ku

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
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.
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
Is the form embedded in some other object (ocx maybe). That could cause problems when centering.
Dear dhammond-ku
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <https://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
Avatar of DanRollins
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
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange