-
October 14th, 2020, 10:43 PM
#1
Why when I add a space to the Label string heterogeneous length of the string ?
Suppose I have 4 Label.Text corresponding to 4 series: Basic salary, Business salary, Responsibility allowance, Attraction allowance. When running the program I can change the string "Responsibility allowance" with another string "Attribution allowance" for example. I take the basic salary series as the standard for other series, from the basic salary series, find the 2-dot character position ":" is position 36 through the function Label1.Text.IndexOf (":"). The other strings that are inserted at the run are "Responsibility allowance" and "Attraction allowance" string, to display four strings uniformly with a 2-dot ":". I insert a space in the string so that the string length at the 2-dot character is equal to the 36th position but when displaying the characters at position 36 as the 2-dot is not equal, I see if the character is different if white characters are less often inserted in string will re-attach, why is that? you see my photo file. How do I write code to overcome this situation ?
http://www.mediafire.com/view/0t4b8j...Space.jpg/file
-
October 15th, 2020, 01:41 AM
#2
Re: Why when I add a space to the Label string heterogeneous length of the string ?
Originally Posted by dongtrien
Please, attach your image to your post! Use this toolbar button:
Attachment 35909
Victor Nijegorodov
-
October 30th, 2020, 06:21 PM
#3
Re: Why when I add a space to the Label string heterogeneous length of the string ?
: is called a colon. As for your question, I'm not sure if you are talking about the actual position or the visible position. Based on your image those colons line up on all but 1 entry but if they were all in position 36 of the string then they would not line up on the display. Keep in mind that you are using a proportional font so some letters are wider than others and therefore you can not count on lining up any character at a give position especially 36 characters in, to much variation in character widths.
If you use a fixed font then all characters including spaces take up the same width and they will line up perfectly.
List of the left uses default proportional font, list on the right uses fixed font. Both have exactly the same text in them.
Last edited by DataMiser; October 30th, 2020 at 06:23 PM.
Always use [code][/code] tags when posting code.
-
November 1st, 2020, 07:03 AM
#4
Re: Why when I add a space to the Label string heterogeneous length of the string ?
Another approach is to make all text labels the same width and to right justify (i.e. align) the text. Then, the text will always align to the right regardless of hiw long the text strings are.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|