在水晶报表中更改列字体样式运行时 [英] Change column font style runtime in crystal report

查看:782
本文介绍了在水晶报表中更改列字体样式运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了使用数据集(具有列名inLanguage1,inLanguage2)的Crystal报表。



此数据集填充数据



例如:
表1在印地语中有名称,并且在表中有两个不同的语言。英语。
表2有英语和印地语的名称。
表3在Kannada和Hindi中有名称。



我使用我的前端(C#)在这些表中存储名称,以使文本框键入该语言的名称。 (对于印地语,我已经将文本框字体设置为Devnagri,我已经安装在我的系统上,因此将显示在textbox属性浏览器中。对于英语,font-type是Arial)。该数据被存储在相应的表中。



现在,当我在运行时获取表数据并填充数据集时,它工作正常。但是,我还想为我打印的报告中的列设置字体。



例如:对于table1,在Crystal报表中,我要设置'Devnagri '作为第一列的字体,第二列的字体为'Arial',如果数据集填充了table2的数据,我想将报表第一列的字体属性设置为'Arial',第二列设置为'Devnagri'

$

解决方案

p> 在Crystal Report中在运行时更改字体样式,字体大小和字体使用以下代码,这将正确运行:



TextObject或FieldObject根据您的条件,使用TextObject。

  TextObject MyText =(TextObject)Repotrdocumentobject.ReportDefinition.ReportObjects [i ]; 

MyText.ApplyFont(new Font(Arial,11f,FontStyle.Bold));

这里 i 是Crystal Report中的TextObject数量, 11f 是字体大小


I have Crystal reports in my project that is designed using a data set (Having table with column name inLanguage1, inLanguage2).

This data set is filled with data from one of the tables from a database, each table have two columns that store names in two different languages.

Eg: Table 1 has name in Hindi and English. Table 2 has name in English and Hindi. Table 3 has name in Kannada and Hindi.

While I store names in these tables, using my frontend (C#), I have set the corresponding font type for the textbox to type the name in that language. (For Hindi, I have set the textbox font as 'Devnagri' which I have installed on my system and so will display in textbox property explorer. For English, font-type is Arial). This data is being stored in corresponding table.

Now, when I fetch table data at run time and fill the data sets it works fine. But, I also want to set the font for the column in the report I am going to print.

Eg: For table1, in Crystal reports I want to set 'Devnagri' as first column's font, second column's font as 'Arial' and, if dataset is filled with data from table2, I want to set font property of report's first column to 'Arial' and second column to 'Devnagri'

So, please suggest a way to do this font setting for Crystal reports in C#.

解决方案

Changing Font style,Font Size,and Font at runtime in Crystal Report use following code,this will run properly:

you can use TextObject or FieldObject Depending on your condition.here am using TextObject.

TextObject MyText = (TextObject)Repotrdocumentobject.ReportDefinition.ReportObjects[i];

MyText.ApplyFont(new Font("Arial", 11f,FontStyle.Bold));

here i is number of TextObject in Crystal Report and 11f is font size

这篇关于在水晶报表中更改列字体样式运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆