如何在运行时更改水晶报表中报表字段的对齐方式 [英] How to change alignment of a report field in crystal reoport at runtime

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

问题描述

在水晶报表中,我想相应地设置字段的对齐方式.我怎样才能在运行时做同样的事情?

In a crystal report, I want to set alignment of a fields accordingly. How can i do the same at run time?

很好.这正在工作.谢谢.我也做了,代码如下所示.

That's nice.This is working.Thanks.I did same, and code is shown below.

var fo = rpt.ReportDefinition.ReportObjects["InvoiceComment"];
fo.ObjectFormat.HorizontalAlignment = Alignment.LeftAlign;
if (ds.Tables[0].Rows[0].ItemArray[19].ToString() == "Right")
    fo.ObjectFormat.HorizontalAlignment = Alignment.RightAlign;
else
    if (ds.Tables[0].Rows[0].ItemArray[19].ToString() == "Center")
        fo.ObjectFormat.HorizontalAlignment  = Alignment.HorizontalCenterAlign;`  

但是我现在遇到了另一个问题.

But I'm going through another problem now.

FieldObject fo = rpt.ReportDefinition.ReportObjects["InvoiceComment"] as FieldObject;                       

var fo = rpt.ReportDefinition.ReportObjects["InvCom"];

显示相同的错误索引超出了数组的范围."如果我使用另一个代码而不是它,它会起作用.

Are showing same error "Index was outside the bounds of the array." And if I use Another code instead of that it works.

FieldObject fo = rpt.ReportDefinition.ReportObjects[35] as FieldObject;                                                       

如何发生这种情况.提前致谢.

How to encurr this. Thanks in Advance.

推荐答案

要更改字段的水平对齐方式,请按照以下步骤操作:

To change the Horizontal Alignment of the field follow the below mentioned steps:

1) 右键单击​​该字段.

1) Right click on the field.

2) 点击格式字段选项.

2) Click on Format Field Option.

3) 选择常用选项卡.

3) Select the Common Tab.

4) 点击Horizo​​ntal Alignment前面的公式编辑器,添加需要的设置.

4) Click the formula editor in front of Horizontal Alignment and add the setting required.

5) 以下是可用的对齐常量:

5) Following are the Alignment constants available:

crDefaultHorAligned           

crLeftAligned                 

crRightAligned                

crCenteredHorizontally        

crJustified  

根据您的标准使用它.

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

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