Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    223

    Unhappy Unanswered: How to "Centre" my Form

    I have set the Form properties as follows:-
    Width - 15cm
    AutoCenter - Yes
    AutoResize - Yes
    Fit To Screen - Yes

    The Background colour of the Details Section goes all the way across the screen??
    But all my Controls stay at the left side of the screen (leaving a big space on the right)

    Is there a way to Centre these Controls in the middle of the screen?
    Last edited by reddevil1; 11-21-12 at 07:02.
    What would you attempt to do if you knew you would not fail?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    don't fit to screen

    or dynamically re align the controls on startup. but I'd strongly suggest at the level you are at its not worth your while...
    it doesn't add anything to the application. Im pretty certain there will be other things that could benefit from your time.


    FWIW Access uses an object, virtually everythign within an Access form or report can be changed on the fly.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not in the middle of the screen, but in the middle of the Form. You use a formula like: Me.ControlName.Left = (Me.WindowWidth/2) -(Me.ControlName.Width/2).
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
        Const c_Offset = -450   ' For a form with a Record Selector
        
        Dim ctl As Control
        
        For Each ctl In Me.Controls
            ctl.Left = (Me.WindowWidth / 2) - (ctl.Width / 2) + c_Offset
        Next ctl
        
    End Sub
    However, this implies that 2 controls cannot be on the same "line" (i.e. the difference between their Top property values must be greater than the height of the controls), which is a problem when you deal with controls that have an associated control (e.g. a TextBox and its Label). Depending on how the form is built, there can also be other constraints and limitations.

    Healdem is right: most of the time it's not worth the trouble.
    Have a nice day!

  4. #4
    Join Date
    Nov 2009
    Posts
    223
    Guys, thanks very much for your feedback.

    I had just found out about Anchoring, and thought I could do everything with that. But there is no Centring option

    So I will take your advice and forget about centering.

    Any reason why I should not Fit To Screen?
    What would you attempt to do if you knew you would not fail?

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    fit to screen is effectively maximise the client window within the Accss application. that means that extra space is added to the rigth and beneath the existing form to pad it to size. NOT selecting the fit to screen option means the form remains as is.


    there are times when you do want to obliterate everything from view or force a user to look at just the one scree (you can also use a modal form for that). however int he windowing design style you should let users play with what ever layout they like, allow them to keep whatever forms open they like PROVIDING they cannot break your system in so doing. its not about the developers choice, its about how the users chooses to use the application


    ferinstance Ive seen users chooisng to keep masterfiel configuration forms open (for things like customers, products and so on, whilst at the same time using that data in client forms such as sales invoice...

    In exactly the same way as linear programming / spaghetti code is frowned on and Object orientated development is flavour of the month/year/decade/century so to is user centric design
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •