如何在gridview的boundfield列中包装文本 [英] How to wrap text in boundfield column of gridview

查看:66
本文介绍了如何在gridview的boundfield列中包装文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有 Width = 850 的Datagird,以及4 BoundColumn ,我希望它们始终在大小相同。



因此,对于每个 BoundColumn ,我给了 ItemStyle-Width =25%。



它正常工作,除非 BoundColumn ,

在这种情况下,它不再是25%, BoundColumn 变得一样长里面的值字符串。



我不希望它像这样,我希望当字符串值很长时,它会被包裹。



字符串将分为2行(或更多), BoundColumn 将保持25%的宽度。



我用Google搜索并找到 ItemStyle-Wrap =True属性BoundColumn ,但它不起作用。



我该怎么办?



有答案吗?

I use a Datagird with Width=850, and 4 BoundColumn, which I want them to be always in the same size.

So, for each BoundColumn, I gave ItemStyle-Width="25%".

It''s working just fine, unless there is a long string in the BoundColumn,
In this case, it''s not 25% anymore, the BoundColumn become as long as the value string inside.

I don''t want it to act like this, I want that when the string value is long, It will be wrapped.

And the string will be divided into 2 lines (or more) and the BoundColumn will stay 25% Width.

I Googled it and found the ItemStyle-Wrap="True" attribute for the BoundColumn, but it''s not working.

What should I do?

Is there any answer?

推荐答案

ItemStyle-Wrap =True通常效果很好,除非字符之间没有空格。

包装是基于单词完成的,这样任何单个单词都不会被破坏两行。



所以ItemStyle-Wrap =True如果您的数据长字符串没有空格,则不适合您。

和问题是你不能自己插入空格,因为这可能会改变数据的含义。



在我之前的项目中遇到过这个问题在网格中显示时,我们只显示了可以容纳在列中然后添加...的长字符串(仅当字符串超出显示的内容时),然后使用了一个工作

添加工具提示以显示完整的字符串。

这样网格格式不受影响,如果用户希望他可以悬停鼠标并看到整个字符串。



希望这有帮助
ItemStyle-Wrap="True" generally works well, except when there is no space between characters.
wrapping is done based on words so that any single word is not broken in two lines.

so ItemStyle-Wrap="True" won''t work for you if your data has long string without space.
and the problem is that you can''t insert spaces on your own because that may change the meaning of data.

in my previous project we encountered this issue and used a work around
while showing in grid we show only that long string which can be accommodated in column and then add "..." (only if string is more than what is showing) and then add a tooltip to show the full string.
that way the grid formatting is not compromised and if user wants he can hover his mouse and see the whole string.

hope this helps


你的 ItemStyle-Wrap =True不工作因为se包装文本内容,文本中应包含''''(SPACE)。文本中的空格并检查它是否会包装你的文字。

您可以使用 \ r \\ nn 空格进行包装。



如果您的文字中没有空格,则将其视为一个单词。
Your ItemStyle-Wrap="True" not working because to Wrap the text contents, text should contain '' ''(SPACE) in it. and the SPACE in your text and check it will wrap your text.
you can use \r\n or a space for wraping.

If you don''t have a SPACE in your text then it is treated as one word.


尝试使用风格属性。风格=白色空间:正常;。这将正确地破坏列中的单词。例如:如果一个句子在列中包含段落作为单词,则上面的解决方案将在段落附近打破并将其包装到下一行。



然而:word-break:word-all等,打破单词然后换行,例如。 paragraph可以在第一行中包含为para,在第二行中包含graph,基于列宽。
Try using "style" attribute . style="white-space:normal;". This will break the words in the columns correctly. eg:If a sentence contains "paragraph" as a word in the column, above solution will break near "paragraph" and wrap it to next line.

Whereas : word-break:word-all etc, breaks the words and then wraps, eg. "paragraph" may be wrapped as "para" in firstline and "graph" in second line, based on the column width.


这篇关于如何在gridview的boundfield列中包装文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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