2016-07-01 80 views
0

我正在使用Visual Studio 2013和水晶报表13.0.12.1494。在我的项目中,我有一个Crystal Report With数据库字段(SQL Server作为数据库)。我在项目设置中存储对字体的引用,并且想要根据用户偏好从项目设置 替换字体,例如,用Arial字体,10PT和用户建立 水晶报表选择Times New Roman字体,12磅在运行时则报告应在Times New Roman字体显示,12磅如何使用vb.net动态更改水晶报表字体

我试过之后没有成功

Dim myparam As New ParameterField Dim myDiscreteValue As New ParameterDiscreteValue myparam.ParameterFieldName = "My Parameter" myDiscreteValue.Value = My.Settings.MyFont.Name

谢谢Advance

回答

1

这里是我用来动态改变我的对象的字体的c#。

文本对象可以是TextObject(简单的文本)或FieldObject(从分贝)

public static void ApplyFontAllText(ReportDocument rapport, Font style) 
    { 

     foreach (ReportObject obj in rapport.ReportDefinition.ReportObjects) 
     { 
      if (obj.GetType().Name.Equals("TextObject")) 
      { 

       ((TextObject)obj).ApplyFont(style); 

      } 
      else if (obj.GetType().Name.Equals("FieldObject")) 
      { 
       ((FieldObject)obj).ApplyFont(style); 
      } 
     } 
    } 

的两个类具有ApplyFont方法。 你可以解析你的字体,然后使用ApplyFont