如何限制标签的长度? [英] How to restrict the length of the label ?

查看:109
本文介绍了如何限制标签的长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EFEXTRA.网络托管 :: Windows Web 托管- ASP ASP . NET ,SQL ...

. Net 以合理的价格提供可靠的Windows Web 托管,并提供快速友好的支持.自 ...


以上区域中,我们一直提供Web 主机服务,该字体由{. Net 提供了可靠的.....},实际上这整个字符数为2000个字符,但在显示单词的确切时间并以...连续时,它的大小受到限制.


我的确切目标是:::

Iam使用gridview显示数据,但是我需要限制字符串长度以使用标签显示数据.

EFEXTRA.NET HOSTING :: Windows Web Hosting - ASP , ASP .NET , SQL ...

.Net provides reliable Windows web hosting with fast and friendly support at affordable prices. We have been providing web hosting services since ...


In
the above area the font which consists of {.Net provides reliable.....}, actually this entire having 2000 chars but it's size restricting while displaying exactly when the word ends and continuous with ....


My Exact Aim Is :::

Iam using a gridview to display data, but i need a string length to be restricted to show the data using label.

推荐答案

您可以开发自定义标签并覆盖OnTextChanged方法

,也可以使用标签的TextChanged事件.

代码应类似于这个

You can develop your custom label and override OnTextChanged  method

or You can use your label's TextChanged event.

code should be like this.

            if (this.Text.Length > 50)
            {
                this.Text = this.Text.Substring(0, 50) + "...";
            }


这篇关于如何限制标签的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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