Format (make bold or italics) a portion of a Textb

2019-02-22 05:03发布

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.

For example:

...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.

3条回答
来,给爷笑一个
2楼-- · 2019-02-22 05:48

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 ...

  • Right Click the field and choose "Format Field"
  • Change Text Interpretation to HTML Text
  • Click 'OK'

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-02-22 05:51

Create a formula for the date part, then embed it into a text box, then you can format any way you like

查看更多
地球回转人心会变
4楼-- · 2019-02-22 05:56

I don't know, if it is doable.

You could create a separate formula field for the value that you want to make bold & insert the formula field between other formula field, which will make it look like single sentence.

查看更多
登录 后发表回答