How to set the fonts for the report

Posted by: rightoguy on 4 August 2017, 2:52 pm EST

  • Posted 4 August 2017, 2:52 pm EST

    Hi,

    I have a few reports and before I run those reports I want to set the font type for all the report based on the user's selection. As far I understand I don't see any properties of the Report where we can set those properties.

    Chow

    Vic
  • Replied 4 August 2017, 2:52 pm EST

    Thank you for posting your solution, it will help future users that run into the same issue.
  • Replied 4 August 2017, 2:52 pm EST

    Each control a report that displaces text has it's own Font property, textbox and label for examples. You can loop through those and change them on demand if you need to. There is also a Font property of a Page object if you are using the DrawText method.

  • Replied 4 August 2017, 2:52 pm EST

    Hi,

    This is what i was wanting to do. For example:
    For Each Control in Report.Controls
        'Change font
    Next


    But the report doesn't have a collection of Controls or maybe I am missing something

    The other option that I can think of is Windows API
    EnumChilWindows and then change font for each control. But I would prefer the first option. If you have any
    code snippet for this one that would be great.

    Chow
  • Replied 4 August 2017, 2:52 pm EST

    Private Sub Command1_Click()
    Dim rpt As New ActiveReport1

    Dim ctrl As Control
       Dim sec As Section
       Set sec = rpt.Sections("Detail")
       For Y = 0 To sec.Controls.Count - 1
          If TypeOf sec.Controls(Y) Is DDActiveReports2.Field Then
             
                sec.Controls(Y).Font.Strikethrough = True
             
                sec.Controls(Y).Font.Name = "Arial"
             
          End If
       Next Y
    rpt.Run
    rpt.Show

    End Sub

    This will run the report ActiveReport1 when a button is clicked and change all field controls to strikethough and Arial.
  • Replied 4 August 2017, 2:52 pm EST

    Thanks a lot guys. I found the solution. This is what I did to make it work. Since I have a lot of subreports inside the main report.
      
        For Each sec In SubReport.Sections
            For Y = 0 To sec.Controls.Count - 1
                If ((TypeOf sec.Controls(Y) Is DDActiveReports2.SubReport) Or _
                    (TypeOf sec.Controls(Y) Is DDActiveReports2.Frame) Or _
                    (TypeOf sec.Controls(Y) Is DDActiveReports2.Shape) Or _
                    (TypeOf sec.Controls(Y) Is DDActiveReports2.Image)) Then
                             'Do nothing
                    Else
                             'font and forclr are set initially
                              sec.Controls(Y).ForeColor = forClr
                              Set sec.Controls(Y).font = font
                End If
            Next Y
        Next

  • Replied 4 August 2017, 2:52 pm EST

    Hi Brian,

    One last question, the richedit control's text doesn't get the correct fonts? Is there any special way to do that?

    Chow

    Vic
  • Replied 4 August 2017, 2:52 pm EST

    How are you assigning the text to the rich edit control?  I was able to change the font by using the richedit control's  .font.fontName = "Arial"
  • Replied 4 August 2017, 2:52 pm EST

    I use the above code to set the fonts for all the controls, but for RichEdit Control it doesn't change. For other controls I get the correct font.
    Also being another problem with the Rich Edit control is the unicode data. I am not sure maybe I am doing something wrong or I don't understand.

    When I assign
    RichEditControl.text = strData, the unicode data is not shown. All I get is ?

    If I assing.

    RichEditContro.TextRTF = strData, then no data is shown on the report..

    I don't understand how it should be done?



  • Replied 4 August 2017, 2:52 pm EST

    Unfortunately, the Rich Edit Control for the COM version of Active Reports does not support unicode.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels