Print Page | Close Window

Dynamic underlining of text

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14449
Printed Date: 29 Mar 2024 at 12:01am


Topic: Dynamic underlining of text
Posted By: Ancient1
Subject: Dynamic underlining of text
Date Posted: 22 Sep 2011 at 3:06am
Does anyone know of a way to dynamically underline text during report execution??  I have a database field that contains a text string where I need to underline some of the text when a specific string occurs in the text string.  I found constants for color, font and so on but nothing to start/stop underlining.  Anyone got a clever trick??



Replies:
Posted By: lockwelle
Date Posted: 22 Sep 2011 at 3:11am
in CR XI on the format object/Font tab there is a button for setting the underline dynamically...but it will affect the entire field, not just a part.
 
unfortunately, while you can type into a textbox and bold or underline a portion of the text, when done dynamically it is all or nothing.
 
HTH


Posted By: DBlank
Date Posted: 22 Sep 2011 at 4:02am
i have split a string into multiple parts using formulas and then dropped the formulas into a text field to recreate the original text. Each formula (string part) can then be conditionally formatted within the text box. This only works if you can logically split your field consitently.


Posted By: lockwelle
Date Posted: 22 Sep 2011 at 5:03am
never thought of that, what a nice solution


Posted By: Ancient1
Date Posted: 22 Sep 2011 at 5:33am
Appreciate the reply.  Unfortunately the text string is a series of values separated by commas and I need to underline one of the values if it occurs in the string.  The location within the string is not consistent.  I guess I was looking for a solution that would act like underlining a portion of text in a Word document (one word, a phrase).  Thanks....


Posted By: DBlank
Date Posted: 22 Sep 2011 at 5:55am
you can do it based on phrase(s).
what is some sample data and what do you want it to do?


Posted By: lockwelle
Date Posted: 22 Sep 2011 at 6:35am
DBlank is correct (it's his solution afterall)
but you could easily have 1 formula like:
shared stringvar sLeft;
shared stringvar sMid;
shared stringvar sRight;
local numbervar i = instr({table.field}, "text desired");
local numbervar ii;
 
if i= 0 then( //not found
  sLeft := {table.field};
  sMid := "";
 sRight := "";
)
else(
  sLeft := LEFT({table.field}, i -1);
  ii = INSTR(i+1, {table.field}, ',");
  if ii = 0 then ii := LEN({table.field}) + 1;
  sMid := MID({table.field}, i, ii - i);
  sRight := MID({table.field}, ii);
)
 
"" //hides the output
 
then you would need 3 access formulas to print each of the shared variables in the textbox with the one accessing sMid to be underlined.
 
I did get this correct DBlank, didn't I? Or do you have another method.
 
If there are multiple sections of the code that will be underlined, well that would make for a much more complex formula.  In addition, if you want to back up to the comma prior to the selected text, you would need call to instrrev. 
 
I am pretty sure that I covered a basic scenario
 
HTH


Posted By: DBlank
Date Posted: 22 Sep 2011 at 7:05am
the premise is the same but as you know I ususally don't use the shared variables Embarrassed



Print Page | Close Window