I have a RDLC Report with a Tablix. The Tablix has a Row bound to a DataSet. The Row has a Textbox with a width of 400px.
If you get a long string with spaces from the DataSet, it will behave as expected and break the string in new lines, making the textbox grow vertically. The problem happens when you get a long string without spaces from the DataSet, the string doesn't break when it reaches the end of the textbox. Instead, the textbox will grow horizontally to fit the string.
How can I break the string and prevent the Textbox from growing horizontally?
After consulting How to maintain long text inside RDLC report column ?
I've found the solution by myself. The RDLC report accepts HTML as Expression, so all you need to do is:
See how the report code changes:
Before:
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!TextoCliente.Value</Value>
<Style>
<FontSize>8pt</FontSize>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
After:
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>="<div style='width:400px'>" & Fields!TextoCliente.Value & "</div>"</Value>
<MarkupType>HTML</MarkupType>
<Style>
<FontSize>8pt</FontSize>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
You can set the Expression in the Designer viewer to avoid having to deal with the replacement of '<' with '<', in that mode, you can just type <.