Vertically centering CanGrow textbox

D

dmcmullen

Stephen Lebans' A2KVerticalJustify.zip
(http://www.lebans.com/verticaljustification.htm) works great for
vertically centering text boxes that have a fixed height (CanGrow=No),
but how can I vertically center a text box if CanGrow=Yes? Then the
following Sub blows up when the text box height grows beyond the
original size (ctl.Height):

Private Sub VerticallyCenter(ctl As Control)
Dim lngHeight As Long

lngHeight = fTextHeight(ctl)
' Rounding will cause a 1 or 2 pixel margin of error
ctl.TopMargin = ((ctl.Height - lngHeight) / 2)

End Sub
 
S

Stephen Lebans

If the TextBox is allowed to grow then why would you need to vertically
center its contents as the TextBox height is driving the growth of the
Section it resides in. If you have other controls that are also driving the
height of the Section then I cannot think of a simple solution OTTOMH. I say
this because it would be relatively simple to output the contents of the
TextBox programmatically via the Report object Print method(sample code on
my site). But when you have CanGrow across page boundaries the logic
required to handle this situation is extremely complex( see the
Justification solution on my site).


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top