Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so lets say this is my code

C#
label1.text = "123456789";


and I see that I just want to only see up to 5, I wanna see this on my label

12345...

but I want this to happen without editing the the label1's text

for example I don't want this to happen

C#
label1.text = "12345...";


I just want it to look like that when I load it on my form, I hope you understand what i'm talking about
Posted

Set label's AutoEllipsis to true.

C#
label1.AutoEllipsis  = true;
 
Share this answer
 
Comments
BillW33 5-Jun-12 9:23am    
Good answer, short and to the point. +5 :)
Sandeep Mewara 5-Jun-12 10:42am    
5!
Oshtri Deka 5-Jun-12 16:05pm    
Thank you both.
[no name] 6-Jun-12 1:59am    
This method doesn't seem to do anything
C#
string str = "123456789";

           if (str.Length > 5)
           {
             label1.Text = string.Concat(str.Substring(0, 5), "...");
           }
           else
           {
               label1.Text = str;
           }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900