reporting services - Truncate textbox content with ellipsis in SSRS -



reporting services - Truncate textbox content with ellipsis in SSRS -

by default, when contents of textbox in ssrs overflows width of textbox, textbox grow vertically accommodate content. feature can turned off, setting "cangrow" property of textbox "false".

however, abruptly cuts off content, not ideal.

i looking way show user text wide fit textbox. in past, i've been using simple look add together ellipsis "...", when length of text string above fixed number:

=iif(len(fields!customername.value) > 25, left(fields!customername.value,23) + "...", fields!customername.value)

but not work when client names contain mixture of capital letters, lowercase letters, punctuation , other stuff makes individual character pixel widths vary wildly.

ideally, property textbox command allow study developer add together ellipsis whenever text not fit in textbox.

does have suggestions more elegant approach this?

another solution i've come with, utilize vb.net, textrenderer.measuretext() function.

to create work, i've added next code report:

public function textwidth(str string) double 'returns width, in pixels, of string, assuming tahoma size 8. dim size system.drawing.sizef dim font new system.drawing.font("tahoma", 8) size = system.windows.forms.textrenderer.measuretext(str, font) textwidth = size.width end function public function textcap(str string, maxwidth integer, optional suffix string = "") string 'truncates string fit within maxwidth pixels, optionally adding suffix string if 'any characters truncated. dim w integer, l integer l = len(str) w = textwidth(str) integer = 1 10 if (w > maxwidth) l = (l * maxwidth / w) if (l < 0) l = 0 exit end if w = textwidth(left(str, l) + suffix) else exit end if next if l < len(str) textcap = left(str, l) + suffix else textcap = left(str, l) end if end function

remember add together references assemblies system.drawing (2.0.0.0) , system.windows.forms (2.0.0.0). textwidth function calculate width of string of text, using tahoma font, size 8. made dynamic adding font name , font size additional parameters both functions.

when calling textcap function ssrs look this:

=code.textcap(fields!customername.value, 150, "...")

the text automatically truncated @ 150 pixels, , suffix argument "..." added in case characters truncated.

reporting-services textbox ssrs-2008 overflow ellipsis

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -