Results 1 to 3 of 3

Thread: problem with setting form height dynamically [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    South Africa
    Posts
    105

    problem with setting form height dynamically [RESOLVED]

    Hi there

    Sorry about another basic question, but it is not working as I expect.

    I am adding controls to a form dynamically, from top to bottom. I want to resize the form so that it extends slightly below the last control. I am trying to do this by taking the top of the last control added, adding the height of the control, adding 50 pixels or so, and making this equal to the height of the form - basically like this:

    VB Code:
    1. Me.height = LastControl.top + LastControl.height + 50

    This does not work though, it cuts off some of the last control. Any ideas how to make this work?

    Many thanks

    langals
    Last edited by langals; May 11th, 2005 at 08:05 AM. Reason: Resolved

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: problem with setting form height dynamically

    The problem is that the size of a Form is not messured in pixels but in Twips. This is true regardless of what you have set the ScaleMode to, since the ScaleMode only changes the client area of the Form (where you place the controls) not the Form itself. So adding 50 twips is not much since there are normally 15 twips per pixel, meaning you're only adding 3 pixels. So the control is cut of because of the height of the form includes is border and the height of the title bar. Try this:
    VB Code:
    1. Me.Height = LastControl.Top + LastControl.Height + 50 + (Me.Height - Me.ScaleHeight)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    South Africa
    Posts
    105

    Re: problem with setting form height dynamically

    Thanks so much. That did the trick

    langals

Posting Permissions

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



Click Here to Expand Forum to Full Width