CanGrow - making them all grow if one needs to

  • Thread starter Thread starter Gregski.co.uk
  • Start date Start date
G

Gregski.co.uk

Hello everyone!

Anybody know the best way to do this? :

Where there are a lot of controls in a row, and one of them needs to make
use of the CanGrow property, how does one then get the others to match the
new height?

What I mean is, how do you avoid this:


11111111111
22222222222
33333333333
4

It should, for neatness, look like this:

11111111111
22222222222
33333333333
44444444444

where all the controls (eg. text boxes) resize whenever one of them decides
it must.........


I take it there'll be a conditional format done on the OnPrint or OnFormat
event..... but not sure how to approach it....
 
Gregski.co.uk said:
Where there are a lot of controls in a row, and one of them needs to make
use of the CanGrow property, how does one then get the others to match the
new height?


You can't make the controls the same height. At the time
you can set their height, it is too soon to know what height
to set them to.

If what you really need is to make their borders the same
size so they look kind of like a spreadsheet, then you can
use the Line method in the Detail sections Print event when
you can determine the appropriate height. The code would
look sort of like:

Me.Line (0, 0) - Step(Me.Width, Me.Height)

to draw a box around the entire detail section. To draw the
verticle lines between the text boxes:

Dim ctl As Control
For Each ctl Me
If ctl.Section = 0 Then
Me.Line (ctl.Left, 0) - Step(0, Me.Height)
End If
Next ctl

There are some tricky situations with KeepTogether, CanGrow,
etc, do it might be better to use Stephen Lebans' PrintLines
module at www.lebans.com
 
Gosh, sounds complicated...... I was thinking of doing a literal comparison
of all the heights so as to ascertain the highest one.... but you're right -
that won't work because the heights will have changed due to the CanGrow
thing..... bummer!

Oh well................ maybe I could set the CanGrow to False, and do it
myself based on the number of characters.......
anyone got any ready-made code for this or do I have to do some work for a
change? lol

G
x
 
Gregski.co.uk said:
Gosh, sounds complicated...... I was thinking of doing a literal comparison
of all the heights so as to ascertain the highest one.... but you're right -
that won't work because the heights will have changed due to the CanGrow
thing..... bummer!

Oh well................ maybe I could set the CanGrow to False, and do it
myself based on the number of characters.......
anyone got any ready-made code for this or do I have to do some work for a
change? lol

The number of characters won't help (unless you're using a
fixed width font such as Courier). Stephen Lebans has a
wealth of stuff on his web site. You could use his
TextHeight function to calculate a text box's CanGrow height
in the Format event, but there are still other things to
keep track of.

I still say that you should use his PrintLines code. Did
you look at Stephen's site?
--
Marsh
MVP [MS Access]


 
Hiya Marshall,

Thanks, am downloading now.... sounds like it might offer a solution..... or
failing that I'll fall back on either character limits for the longest
fields (testing the height based on the fattest characters like W or X or M)
or just generous heights.....

Cheers
Gregski
 
Back
Top