
Dynamically move/resize controls on resized form
Matt, I don't see anything wrong with your logic (assuming
that no button is >= 3/8ths of an inch high) so I'm just
guessing here.
Personally, I don't like to spend so much time in the Resize
event. I get the feeling(?) that it loses track of
something as the resize event can be triggered very rapidly.
A way to simplify this case would be to move the buttons to
the form's footer so you don't have to recalculate their
position. Of course, you would have to modify the
expression for the list box height like this:
lstStudents.Height = Me.InsideHeight - (0.8 * 1440) -
Me.Section(2).Height
Marsh
Quote:
>I am trying to write an event procedure to dynamically move
& resize the
>controls on a form when the form itself is resized. My
form has one large
>listbox with a row of buttons underneath. Basically I just
want to resize
>the listbox so that it fills most of the window, and move
the buttons so
>that they stay just above the bottom of the window. Here's
my code:
>Private Sub Form_Resize()
> Dim ctl As Control
> lstStudents.Width = Me.InsideWidth - (0.25 * 1440)
> lstStudents.Height = Me.InsideHeight - (0.8 * 1440)
> For Each ctl In Me.Controls
> If ctl.ControlType = acCommandButton Then
> ctl.Top = Me.InsideHeight - (0.375 * 1440)
> End If
> Next
>End Sub
>Using this code I can resize horizontally just fine.
However, the problem
Quote:
>is that if I resize the form vertically past a certain
point, I get
>"Run-time error '2100': The control or subform control is
too large for this
>location" on the line setting ctl.Top = me.InsideHeight -
(0.375 * 1440).
>The bizarre thing is that the actual Me.InsideHeight
threshold past which I
Quote:
>get this error is inconsistent. Sometimes it's very low
(like 5700 twips),
>other times its much higher (like 9000 twips). Any ideas?