Link to home
Start Free TrialLog in
Avatar of jtesdall
jtesdall

asked on

Set font programatically on text object in CR.net

I am trying to dynamically set the font and color of a text object in a section of a cr.net report. The code listed only sets the color and font on the first embedded field. These are simple database generated address labels but I canoo figure out how to access (reference) individual embeded fields or tell the report to set the font and color on the completetext object.
Dim section As Section = report.ReportDefinition.Sections.Item("Section3")
        Dim textObject As TextObject = section.ReportObjects("Text4")
 
        textObject.Color = Color.Red
        textObject.ApplyFont(New Font("Arial", 8.25F))

Open in new window

Avatar of Mike McCracken
Mike McCracken

I don't believe you can dynamically access the individual embedded fields.

You can format them by selecting them from the textbox and right clicking
Choose FORMAT FIELD
You should be able to use the formula buttons on the FONT tab to set the values you want.

mlmcc
Avatar of jtesdall

ASKER

Yes, but I want to do this programatically. Basically based on certain criteria at runtime I want to change the font and color on these labels.

I may have found a solution but it is a work around. I duplicated the text object and set the new font and color I want. Then at runtime I set the length of the text object I don't want to zero so the one I do want displays. This seems to work for now, but setting the font on the text object should have worked for the whole object instead of just the first embedded field. I guess this is a bug.
The formula method I mentioned is at runtime.  Is the information you use to set the color available in the report?

mlmcc
No its not. I just want people to be able to select a standard font or script font for printing out address labels from our database with my VB.net app.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why were points awarded for this solution? It doesn't say anything!