|
-
Aug 25th, 2009, 09:18 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Label not centering on form
Code:
Private Sub Form_Load()
Me.WindowState = 2
With Label1
.Move (ScaleWidth - .Width) / 2, (ScaleHeight - .Height) / 2
End With
End Sub
Can anybody suggest why the label is not centering on the form using this code?
"And then one day you find, ten years have got behind you.
No one told you when to run, you missed the starting gun."
-
Aug 25th, 2009, 09:21 AM
#2
Re: Label not centering on form
The form may not be resized yet. Try adding a DoEvents after setting the window state.
Tip: Add the label positioning to the form's Resize event vs the Load event. If you do, also check to ensure the WindowState<>vbMinimized before repositioning the label, because you will get an error positioning controls while form is minimized.
-
Aug 25th, 2009, 09:34 AM
#3
Thread Starter
Addicted Member
Re: Label not centering on form
 Originally Posted by LaVolpe
The form may not be resized yet. Try adding a DoEvents after setting the window state.
Tip: Add the label positioning to the form's Resize event vs the Load event. If you do, also check to ensure the WindowState<>vbMinimized before repositioning the label, because you will get an error positioning controls while form is minimized.
I added the label positioning to the form's resize event and that worked, thanks....
"And then one day you find, ten years have got behind you.
No one told you when to run, you missed the starting gun."
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
|