rfresh Well-Known Member Licensed User Longtime User Mar 5, 2012 #1 I know this should be an easy thing to figure out, but my code to auto-center label text isn't working the way I want. I have 3 labels of varying text length. What I expected to see on the screen was something like this (I'm using underscore on this post as spaces otherwise spaces are removed): _____This is label text line one ___This is label text line one two This is label text line one two three But what I got was this: This is label text line one This is label text line one two This is label text line one two three My code: Code: Copy bl_Title.Left = (pScreenWidth - lbl_Title.Width) / 2 But clearly this is not right? Thanks...
I know this should be an easy thing to figure out, but my code to auto-center label text isn't working the way I want. I have 3 labels of varying text length. What I expected to see on the screen was something like this (I'm using underscore on this post as spaces otherwise spaces are removed): _____This is label text line one ___This is label text line one two This is label text line one two three But what I got was this: This is label text line one This is label text line one two This is label text line one two three My code: Code: Copy bl_Title.Left = (pScreenWidth - lbl_Title.Width) / 2 But clearly this is not right? Thanks...
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2012 #2 Have you set the horizontal alignment to CENTER in the designer? Upvote 0
S Smee Well-Known Member Licensed User Longtime User Jun 15, 2012 #3 Erel said: Have you set the horizontal alignment to CENTER in the designer? Click to expand... Can this be done if not using the designer. i.e adding it in code? Upvote 0
Erel said: Have you set the horizontal alignment to CENTER in the designer? Click to expand... Can this be done if not using the designer. i.e adding it in code?
Ricky D Well-Known Member Licensed User Longtime User Jun 15, 2012 #4 try this Code: Copy Dim l As Label l.Gravity = Gravity.CENTER_HORIZONTAL it's as simple as that! regards, Ricky Upvote 0
try this Code: Copy Dim l As Label l.Gravity = Gravity.CENTER_HORIZONTAL it's as simple as that! regards, Ricky
S Smee Well-Known Member Licensed User Longtime User Jun 15, 2012 #5 Thanks Ricky :sign0148: Upvote 0