View Single Post
 
Old 04-24-2015, 12:46 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

That kind of thing could happen in VB6 as well, but more rarely. You sometimes had to do a Me.Show to make the form visible before trying to read some things because some properties aren't actually valid until the control is drawn.
That said, I tried it and I got 200, in all the places that I tried, so I don't know why you're showing 150 in your case.
Code:
Public Class Form1

  Private Sub Form1_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
    Debug.Print("Picturebox1 size in Activated Event: {0}", PictureBox1.Size.ToString)
  End Sub

  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Me.Text = CStr(PictureBox1.Width)
    Debug.Print("Picturebox1 size in Load Event: {0}", PictureBox1.Size.ToString)
  End Sub

  Private Sub Form1_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
    Debug.Print("Picturebox1 size in Shown Event: {0}", PictureBox1.Size.ToString)
  End Sub
End Class
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote