Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Go Back  Xtreme Visual Basic Talk > > > Picturebox size in design phase & while running MISMATCH


Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2015, 10:46 AM
Oswald Oswald is offline
Regular
 
Join Date: Apr 2005
Posts: 63
Default Picturebox size in design phase & while running MISMATCH


how is this possible? I'm new to .net, but I know it doesnt scale at all like vb6.

see the attachment for picturebox size and what the output was (on form title).

its set to 200 in the IDE, and form_load returns 150, without doing anything else, this was a blank project to make sure everything is default

Code:
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = CStr(PictureBox1.Width)
    End Sub
End Class
Attached Images
File Type: png b1.png (12.5 KB, 3 views)
File Type: png b2.png (2.8 KB, 3 views)
Reply With Quote
  #2  
Old 04-24-2015, 12:46 PM
passel's Avatar
passelPicturebox size in design phase & while running MISMATCH passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,015
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
  #3  
Old 04-24-2015, 01:45 PM
Oswald Oswald is offline
Regular
 
Join Date: Apr 2005
Posts: 63
Default

thanks for the effort. well, finally I invstigated and its the same problem I had with VB6 and XP once. I've changed the size of "gui elements" to be bigger in windows, and it affects control sizing implicitly somewhere somehow.
Reply With Quote
  #4  
Old 04-24-2015, 04:00 PM
Gruff's Avatar
GruffPicturebox size in design phase & while running MISMATCH Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

My take on it is that you cannot trust sizes in the form_load event as graphics have not been generated at that point.

In vb6 I used to use a timer control set for a couple of seconds after form_load.
In the timer event I would do my graphics measurement.


In VB.NET you should use the Form_Shown event as Passel shows or the SizeChanged event if you are creating a control.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
 
Picturebox size in design phase & while running MISMATCH
Picturebox size in design phase & while running MISMATCH
 
-->