last day (15 days later) » 

3:52 PM
0
Q: Why the Label width calculation differs for alphabets and special symbols

SivasubramanianI am binding a label to a text(I have used INotifyPropertyChanged). I have subscribed the SizeChanged Event of the Label Lets consider the initial value of the text is "-9999" and the same value is displayed in the label. Then i change the text value to "-1111". The number of characters before ...

 
I think this is normal if you are not using fixed-width font
 
@Bolu : In my project i need to set any fonts. I cannot restrict it to fixed width fonts.
Yes, as sheridan says this solution cannot be applicable to my project.
 
So you need to find another way. Tell us what you want to achieve, why you need to handle SizeChanged event?
 
You guys have anyother solution??
My requirement is when the number of the characters is not changed the width should not be changed.
 
...then you need to use a fixed width fonts. If you can't use it, then you can't... my comments above is asking why do you need the width to be fixed when the number of characters is not changed. Please ask the real question: What is the XY problem?, it will be better if you have a screenshot.
 
3:52 PM
I am having a ticker control whcih scrolls from right to left. I have labels which contains text. while scrolling when the label width is changed it looks as if it is a lag in the scroll and its ugly.
Am I clear now?
 
Say if your label has a width that can show 6 characters, then if you have 10 characters in the label, do you want any extra characters become invisible to the user? If this is fine by you, then you can give a fixed size to your label, or put it in a fixed-width grid column?
 
When I get 10 characters and the width is changed I will restart the entire scrolling ticker because the chances for the characters to change is rare. (But it happens) But every second the minus an plus symbols change, and also the font size can be changed dynamically.
HI @Bolu : Thanks for your interset and patience
 
I still not 100% understand your problem, so why don't you restart the scrolling ticker when every time text is changed? what is a scrolling ticker??
 
The fixed-width font solution you provide exactly solves my problem but unfortunately the fonts are not limited. Now i am using verdana, in future it may change to any fonts
 
OK, how about use 2 labels, one for the special symbols (+ or -) with a fixed size slightly larger then it should be to give you more capability for other fonts, and the other label for the number??
 
4:06 PM
Yes, Sounds Great, Its always going to be either '-' or '+', like you said i can use a separate label and set a fixed size , when the fontSize changes i can handle it and set the new width to the symbol label.
I found a solution which uses Multibinding and when the text changes it calculates the number of old and new characters and set width based on that each time. but your solution is very simple. Thanks a lot
 
no problem
 

last day (15 days later) »