Posted 13 March 2020, 6:48 am EST
I am hoping to display different text in a section report text box if the text is too long for the text box.
Is this the correct way to do it?
Public Class SectionReport1
Private Counter As Integer = 0
Dim Text1 As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas aliquet hendrerit tortor"
Private Sub SectionReport1_DataInitialize(sender As Object, e As EventArgs) Handles Me.DataInitialize
Fields.Add("Test")
End Sub
Private Sub Detail_Format(sender As Object, e As EventArgs) Handles Detail.Format
If CurrentPage.MeasureText(Text1).Width > TextBox1.Width Then
TextBox1.Text = "TOO LONG"
End If
End Sub
Private Sub SectionReport1_FetchData(sender As Object, eArgs As FetchEventArgs) Handles Me.FetchData
Counter += 1
If Counter = 10 Then
eArgs.EOF = True
Return
End If
Fields("Test").Value = Text1
eArgs.EOF = False
End Sub
End Class
The code above is not accurate enough, since the ‘TOO LONG’ message does not display even though the text is truncated.
John