Label.Text Property

rfresh

Well-Known Member
Licensed User
Longtime User
I'm trying to change the text of a Label but when I change it, part of the text that was there before still remains visible. I have tried to set the .Text = "" but it didn't make any difference. So I end up with what looks like garbage text after trying to edit the .Text property.

Any idea's as to what is causing this?

Thanks...
 

JonPM

Well-Known Member
Licensed User
Longtime User
Are you adding the label to a panel or initializing it in the same event?
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
If you do this:
B4X:
Label1.Text = "Hello"

It will overwrite whatever had before, can you post your code to see what are you doing?

I tried

B4X:
Label1.Text = "        "

but it still garbled the text!
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
What I discovered is that in the Designer, I had added the text of the label in the .Text property. Then when trying to dynamically change the .Text in code, the original text would remain on the screen while the dynamic code over wrote it but didn't actually remove it!! Strange!

When I removed the .Text string in the Designer, and left it blank, the dynamic code changes to the .Text property displayed cleanly as it should and as one would expect.

I don't understand why having a text string in the Designer label .Text field would mess this up later when changing it programatically, but it did and once I removed it, the code was able to change the text field cleanly.
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Where are you calling the LoadLayout? It probably has something to do with this.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Thanks...that's probably what is causing my issue. I'll read that link again.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…