Navigation:  Articles > May-1998 >

Tip: Vertical Line in Detail Sections

Previous pageReturn to chapter overviewNext page

Militaru Sorin          
 
Rather than draw lines on your reports (or use the Line control), this routine, CreateVerticalLines, draws vertical lines between every text box on your report. It will also work in situations where the Line control won't. CreateVerticalLines has to be called in the OnPrint event for every Detail Section in the report by using:
 

Call CreateVerticalLines(Me)

 
The routine finds the largest text box in the section and uses it to determine the height of the vertical lines. It then draws a line on between each text box (and at the beginning and end of the line, too).
 

Sub CreateVerticalLines (rptCurrent As Report)

 

Dim intMaxHeight As Integer

Dim intControlsNo As Integer

Dim intCounter As Integer

 

intMaxHeight = 0

 

' Determe maximum height of text boxes in Detail Section

intControlsNo = rptCurrent.Count

For intCounter = 0 To intControlsNo - 1

  If rptCurrent(intCounter).Section = 0 Then

    If TypeOf rptCurrent(intCounter) Is TextBox Then

      If rptCurrent(intCounter).Height > _

       intMaxHeight Then

        intMaxHeight = rptCurrent(intCounter).Height

      End If

    End If

Emd If

Next intCounter

 

' Drawing first line

rptCurrent.Line (0, 0)-Step(0, intMaxHeight)

 

' Drawing the lines from right side of controls

For intCounter = 0 To intControlsNo - 1

  If rptCurrent(intCounter).Section = 0 Then

    If TypeOf rptCurrent(intCounter) Is TextBox Then

      rptCurrent.Line (rptCurrent(intCounter).left + _

        rptCurrent(intCounter).width, 0)- _

        Step(0, intMaxHeight)

    End If

  End If

Next intCounter

 

End Sub