Solved

Form refuses to center

Posted on 2002-06-22
9
215 Views
Last Modified: 2010-05-02
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
Comment
Question by:forrestx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7100923
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
 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 7101041
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
 

Expert Comment

by:dhammond-ku
ID: 7101407
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 38

Expert Comment

by:PaulHews
ID: 7101606
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
 

Expert Comment

by:dhammond-ku
ID: 7102602
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
 
LVL 1

Expert Comment

by:alaplume
ID: 7212050
Is the form embedded in some other object (ocx maybe). That could cause problems when centering.
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7522851
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7923784
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
 

Expert Comment

by:SpideyMod
ID: 7968481
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 101
I need help using System.Web.HttpUtility.HtmlEncode in my VB.Net application 3 128
Help me. 3 78
Set email body to html using vbscript 6 93
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question