|
-
Jul 18th, 2010, 05:40 AM
#1
Thread Starter
Junior Member
[SOLVED] Changing label location?
Well, title explains all, if the users clicks on a setting the text of a label will change, but its not aligned so I want to get it aligned, anyone knows the code for this?
Label1.Location and then?
Label1.Location (blabla ;blabla) won't work so..
Last edited by Imperoto; Jul 18th, 2010 at 06:19 AM.
Reason: solved
-
Jul 18th, 2010, 05:45 AM
#2
Re: Changing label location?
Aligned how? You might to provide a clearer explanation of EXACTLY what you want to happen.
-
Jul 18th, 2010, 05:53 AM
#3
Thread Starter
Junior Member
Re: Changing label location?
Okay, okay, so, the user can determine if he wants to use the function keys (F1-F10) or the Numpad (0-9)
If I use the function keys, underneath the button is a label showing which function key it is, in this case it's F1.
Now, if I change to the NumPad keys, the text of the label underneath changes to NumPad 0, but it ain't in the middle of the button, get me? Here's an image I quickly created;
So I need to change the location of the label, but I don't know how..
-
Jul 18th, 2010, 06:00 AM
#4
Addicted Member
Re: Changing label location?
before youchange the text, you can use lable1.location = new point(X, Y)
in your case, you shouls change only X, and replace Y with: label1.location.Y
im sure you can figure it out from here
btw, i think that there is simpler solution with automatical alignment in properties, but im not really sure
-
Jul 18th, 2010, 06:03 AM
#5
Member
Re: Changing label location?
To change the location, use something like this.
vb Code:
label1.location = new Point(x, y)
To make sure it's in the middle you need to find the center of the button.
vb Code:
buttonCenter = button1.left + (button.width/2)
Then use this to set the labels x co-ord.
vb Code:
x = buttonCenter - (label1.width/2)
Hope this helps.
-
Jul 18th, 2010, 06:19 AM
#6
Thread Starter
Junior Member
Re: Changing label location?
Thanks guys, I've sorted it out :-)
-
Jul 18th, 2010, 06:26 AM
#7
Re: [SOLVED] Changing label location?
You don't need any code at all for this:
1. Set the Label's AutoSize property to False.
2. Set the Label's TextAlign property to TopCenter.
3. Align the centres of the Button and the Label (Hint: there's a button on the toolbar to do that, after you've selected both controls).
That's it. Just make sure that the Label is wide enough to accommodate any text you might want to display and the rest happens automatically.
For future reference, if you succinctly explain what it actually is that you want then you're likely to get the answer you want earlier. If you had said "how can I keep the text in a Label aligned to the centre of a Button" then I'd have known straight away.
-
Jul 18th, 2010, 06:34 AM
#8
Thread Starter
Junior Member
Re: [SOLVED] Changing label location?
 Originally Posted by jmcilhinney
You don't need any code at all for this:
1. Set the Label's AutoSize property to False.
2. Set the Label's TextAlign property to TopCenter.
3. Align the centres of the Button and the Label (Hint: there's a button on the toolbar to do that, after you've selected both controls).
That's it. Just make sure that the Label is wide enough to accommodate any text you might want to display and the rest happens automatically.
For future reference, if you succinctly explain what it actually is that you want then you're likely to get the answer you want earlier. If you had said "how can I keep the text in a Label aligned to the centre of a Button" then I'd have known straight away.
Thanks ;-)
It's true that I should explain more detailed and easier but hey, english isn't my mother language, so I don't always know how to explain something you see ;-)
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
|