Click here to Skip to main content
Rate this: bad
good
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
good
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!!
  Permalink  
Comments
Anju Sadanandan at 2-Feb-13 5:15am
   
thank u
Rate this: bad
good
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[^]
  Permalink  

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

  Print Answers RSS
0 CHill60 360
1 OriginalGriff 343
2 Sarvesh Kumar Gupta 168
3 RyanDev 145
4 Sergey Alexandrovich Kryukov 128


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