在 Crystal Reports 中格式化(加粗​​或斜体)文本框或公式对象的一部分 [英] Format (make bold or italics) a portion of a Textbox or Formula object in Crystal Reports

查看:10
本文介绍了在 Crystal Reports 中格式化(加粗​​或斜体)文本框或公式对象的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Crystal Reports for Visual Studio 2008 中仅格式化(粗体或斜体)文本框或公式对象 (IFieldObject) 的一部分.

I am trying to format (bold or italics) only a portion of a textbox or Formula object (IFieldObject) in Crystal Reports for Visual Studio 2008.

我知道如何使整个字段加粗,但我只想要一部分.

I know how to make the entire field bold, but I want only a portion.

例如:

...blah blah blah 2009 年 5 月 12 日 blah blah blah...

...blah blah blah May 12, 2009 blah blah blah...

这可能吗?我在想一定有某种标记,但找不到任何参考给它.

Is this possible? I'm thinking there must be some sort of markup, but can't find any reference to it.

推荐答案

您可以通过在字段中插入 HTML 标记(使用公式)然后将新公式显示为 HTML 字段来完成此操作.

You can do this by inserting HTML markup in the field (using a formula) and then displaying the new formula as a HTML field.

例如这是一个基本的语法公式,它接受一个字段并在冒号前的文本周围添加粗体标记.

e.g. Here's a basic Syntax formula that takes a field and adds the bold tag around the text before the colon.

dim sTmp as string 
dim sLeft as string 
dim sRight as string 
dim sAll as string 

sTmp = {yourtable.yourfield}

sLeft = (split(sTmp,":"))(1)
sRight = (split(sTmp,":"))(2)

sAll = "<b>"+sLeft+":</b>"+sRight
formula = sAll

如果您将这个新公式放入报告中,然后...

If you place this new formula into the report and then ...

  • 右键单击字段并选择格式化字段"
  • 将文本解释更改为 HTML 文本
  • 点击确定"

这里有陷阱.原始文本不是 HTML 编码的,我确信我的示例代码在大约十行内完成了一个简单的单行操作.此外,如果您的字段中没有冒号,您将强制出错.但是,它应该给你正确的想法.

There are Gotchas here. The original text is not HTML encoded, and I'm sure my example code does a simple one-line thing in about ten lines. Also, if your field has no colons in it, you'll force an error. However, it should give you the right idea.

这篇关于在 Crystal Reports 中格式化(加粗​​或斜体)文本框或公式对象的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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