How can multiple controls have the same height when using CanGrow

  • Thread starter Thread starter Julie B.
  • Start date Start date
J

Julie B.

Hi,

Thanks for helping me with the following issues.

In a report, I have many field in the details section that I set to CanGrow.
They all need to have a border.

But when printing, the borders have different sizes which looks pretty weird !

How can I have multiple controls have the same height when using CanGrow ?

Thanks alot !

Julie
 
Hi,

Thanks for helping me with the following issues.

In a report, I have many field in the details section that I set to CanGrow.
They all need to have a border.

But when printing, the borders have different sizes which looks pretty weird !

How can I have multiple controls have the same height when using CanGrow ?

Thanks alot !

Julie

You mean you wish to enclose each control in a box, sized to the
tallest control on that line?

In the Detail Section, set each control's Border property to
Transparent.
Set the Detail Section's CanGrow property to Yes.
Set each control's CanGrow property to Yes.
Size all of the controls to the same Height.

Place the following code in the Report Detail Print event:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
' draws a box around each control,
' set to the height of the tallest control on that line.

Dim lngHeight As Long
Dim X1 As Single
Dim Y1 As Single
Dim Y2 As Single
Dim X2 As Single

Me.DrawStyle = 0

' Find the height of the tallest control in the row
Dim c As Control
For Each c In Me.Section(0).Controls
If c.Height > lngHeight Then
lngHeight = c.Height
End If
Next

' Draw the box around the record
For Each c In Me.Section(0).Controls
X1 = c.Left
X2 = c.Left + c.Width
Y1 = c.Top
Y2 = lngHeight
Me.Line (X1, Y1)-(X2, Y2), vbBlack, B
Next c

End Sub
 
Back
Top