|
-
May 11th, 2005, 07:44 AM
#1
Thread Starter
Lively Member
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:
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
-
May 11th, 2005, 08:00 AM
#2
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:
Me.Height = LastControl.Top + LastControl.Height + 50 + (Me.Height - Me.ScaleHeight)
-
May 11th, 2005, 08:05 AM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|