Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
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...
Posted 1-Feb-13 22:00pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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!!
Anju Sadanandan at 2-Feb-13 5:15am
thank u
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 487
1 CPallini 345
2 OriginalGriff 240
3 George Jonsson 159
4 Abdul Samad KP 145
0 OriginalGriff 6,329
1 Sergey Alexandrovich Kryukov 5,700
2 CPallini 4,940
3 George Jonsson 3,469
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100