.net – 如何使标签控件截断带有省略号的长字符串?

栏目: ASP.NET · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/15337675/how-do-i-make-a-label-control-truncate-long-strings-with-an-ellipsis

我有一个带有更改文本的标签,我希望它是一个固定长度的单行.每当文本长度超过标签长度时,我希望它显示最后与“…”匹配的内容.例如:

Some Very Long Text

看起来像:

Some Very Lon...

有谁知道这是怎么做到的吗?

其中一个选项是将 Label.AutoEllipsis

设置为true.

Set AutoEllipsis to true to display text that extends beyond the width of the Label when the user passes over the control with the mouse. If AutoSize is true, the label will grow to fit the text and an ellipsis will not appear.

因此,您需要将AutoSize设置为false.省略号外观取决于标签的固定宽度. AFAIK,您需要手动处理文本更改以使其依赖于文本长度.

翻译自:https://stackoverflow.com/questions/15337675/how-do-i-make-a-label-control-truncate-long-strings-with-an-ellipsis


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms of the Intelligent Web

Algorithms of the Intelligent Web

Haralambos Marmanis、Dmitry Babenko / Manning Publications / 2009-7-8 / GBP 28.99

Web 2.0 applications provide a rich user experience, but the parts you can't see are just as important-and impressive. They use powerful techniques to process information intelligently and offer featu......一起来看看 《Algorithms of the Intelligent Web》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具