如何保持RDLC报告列里长的文本? [英] How to maintain long text inside RDLC report column ?

查看:327
本文介绍了如何保持RDLC报告列里长的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了很多,以保持RDLC报告中列里长的文本,但它似乎不可调。当有些长文本出现的任何列内,则它扰乱了整个报告。如何控制它,所以文中保持适当和良好的方式向下延伸。

在这里输入的形象描述


解决方案

尝试,把一个固定的列宽,并设置可以扩大为False,并确保该行有它在真正的设置。

如果不工作,你必须把它给记者之前,编辑您的数据源。你必须打破值成基于所述字符串的长度多行。您可以通过插入 System.Environment.NewLine 每次超过大小时实现这一目标。在你需要插入换行符的确切长度取决于你的最大列宽,你就会有,直到找到完美契合这种通过试验和错误计算自己。


修改:包含循序渐进的过程基于文本的大小将断裂线


  

计算字符串的长度,并添加 Environment.NewLine 在需要的地方强制文本突破到一个新行。


  
  

      
  1. 使用 Graphics.MeasureString 来计算像素文本的大小。

  2.   
  3. 检查宽度超过你的文本框的最大长度。
      
      

        
    • 如果字符串配合,将其添加到最终的字符串,并继续执行步骤的 4

    •   
    • 如果字符串不适合,继续加强的 3

    •   

  4.   
  5. 删除字符串的字符,再插入字符到一个新的(第二),刺痛,重复步骤的 1 的前面,直到
      第一个字符串相符。

  6.   
  7. 检查第二个字符串是空的。
      
      

        
    • 如果第二个字符串是空的,我们就完蛋了。 (最后的字符串可以被添加到TextBox /新的数据源)。

    •   
    • 如果第二个字符串不是空的,添加一个 Environment.NewLine 在最后一个字符串的结束和替换为第一个字符串
        第二个,并重新做第二串空,重复整个
        流程。

    •   

  8.   

有可能会改善这一进程的途径。例如,通过打破固定的predefined间隔文本事后提炼它。或者,如果有空格分割实际的话,你可以添加和删除的词代替字符。

I have tried a lot to maintain long text inside RDLC report's columns but it doesn't seem to be adjustable. When some long text appears inside any column then it disturbs the whole report. How to control it, so the text keeps extending downwards in proper and good manner.

解决方案

Try and put a fixed Column Width and set CanGrow to False and make sure that the Row has it set on True.

If that doesn't work you'll have to edit your datasource before giving it to the reporter. You must break the value into multiple lines based on the length of the string. You can achieve this by inserting System.Environment.NewLine every time it exceeds the size. The exact length at which you need to insert the line breaks depends on your maximum column width and you'll have to calculate this yourself by trial and error until you find the perfect fit.


Edit: Including step by step process for adding break lines based on text size.

Calculate the length of the string and add Environment.NewLine where needed to force the text to break to a new line.

  1. Use Graphics.MeasureString to calculate the size of your text in pixels.
  2. Check if the width exceeds the maximum length of your TextBox.
    • If the string fits, add it to the final string and continue to step 4.
    • If the string doesn't fit, continue to step 3.
  3. Remove a character of the string, insert that character to the front of a new (second) sting and repeat step 1. again until the first string fits.
  4. Check if the second string is empty.
    • If the second string is empty, we're finished. (The final string can be added to the TextBox / new datasource).
    • If the second string isn't empty, add an Environment.NewLine at the end of the final string and replace the first string with the second one and make the second string empty again, repeat the whole process.

There might be ways of improving this process. For example by breaking the text in fixed predefined intervals and refining it afterwards. Or if there are actual words divided by spaces you could add and remove words instead of characters.

这篇关于如何保持RDLC报告列里长的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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