简体   繁体   中英

Set crystal report textobject bold at runtime using C#

I'm updating text objects in my Crystal report in the C# code like this,

ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Environment.CurrentDirectory + @"\Test.rpt");
TextObject txtTest = (TextObject)rptDoc.ReportDefinition.ReportObjects["txtTest"];
txtTest.Text = "Test";

Now I want to bold the text in "txtTest" text object.

I'm looking for something like this,

txtTest.Font.Bold = true;

But unfortunately it is read-only.

Finally, I have found a solution.

System.Drawing.Font font1 = new System.Drawing.Font("Arial", 12, FontStyle.Bold);
txtTest.ApplyFont(font1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM