限制标签页标题上显示的文本长度 [英] Limit the length of text displayed on the header of tabpage

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

问题描述

我的项目是实现一个浏览器。我有一个winform,其中动态添加了tabpages。加载网站后,网页标题将显示在所选标签页的标题上。 tabheader的大小受代码限制。但是当添加冗长的标题时,它超过了tabheader的大小。请帮助我通过显示文本的起始部分填写标题限制内的文本。

例如:而不是W3schools在线教程我想将它显示为W3schools Onli ...

My project is to implement a browser. I have a winform in which tabpages are added dynamically. After loading a site the title of the webpage is displayed on the title of the selected tabpage. Size of the tabheader is limited by code.But when a lengthy title is added it exceeds the size of the tabheader. Please help me to fill the text within the limit of header by displaying the starting portion of the text.
for eg: instead of W3schools Online Tutorial i want to display it as W3schools Onli...

推荐答案

首先在加载标题之前在标题中选择你想要的最大字符串长度,使用如下所示: -





First choose what max length of string you want in the header before loading the title use something like below:-


//assume max len 10 and 3 dots means you should show only 7 chars and three dots
        string title = "Ravi malviya"; //example only
        title = title.Substring(0, 7);
        title += "...";





祝您好运!!



Best of luck!!


要获得省略号的好位置,您需要测量文本,找到您所在的位置可以放置它。您可以或多或少地使用本文的代码,但几乎不做任何修改: Auto Ellipsis [ ^ ]
To have a good position of the ellipsis you need to measure the text, find the position where you could place it. You could use the code of this article more or less as it is, but with little modifications for sure: Auto Ellipsis[^]


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

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