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..
Printable View
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..
Aligned how? You might to provide a clearer explanation of EXACTLY what you want to happen.
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..
http://i25.tinypic.com/dy535j.png
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
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.
Thanks guys, I've sorted it out :-)
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.