473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Get PictureBox with x height returned size of previously loaded image

I'm using VS 2005.
When user selects a image from the FileListBox, the code is
PictureBox.ImageLocation = sFullPath
PictureBox is set to AutoSize. When the newly loaded image is smaller
than the panel size, I want to center it within the panel by
calculating and move the box to a location other than (0,0). The
problem is that when retrieving the current box size
(PictureBox.Width/Height), it returns the previously auto sized
dimensions (base on the previously loaded image). Seems like I need to
run a "wait" function to wait for the new image to be fully loaded AND
the picbox's done auto sizing to get the correct size. How do I do
that?

Jan 12 '06 #1
3 4069
I haven't tested this, but what if you do "Application.DoEvents" after
setting the ImageLocation? Then does it return the correct size?

"te***@yahoo.com" wrote:
I'm using VS 2005.
When user selects a image from the FileListBox, the code is
PictureBox.ImageLocation = sFullPath
PictureBox is set to AutoSize. When the newly loaded image is smaller
than the panel size, I want to center it within the panel by
calculating and move the box to a location other than (0,0). The
problem is that when retrieving the current box size
(PictureBox.Width/Height), it returns the previously auto sized
dimensions (base on the previously loaded image). Seems like I need to
run a "wait" function to wait for the new image to be fully loaded AND
the picbox's done auto sizing to get the correct size. How do I do
that?

Jan 12 '06 #2
Could you try to retrieve the image file into a System.Drawing.Image, get
its Height and Width, center the PictureBox and then set PictureBox.Image
property rather than ImageLocation?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
<te***@yahoo.com> escribió en el mensaje
news:11**********************@g49g2000cwa.googlegr oups.com...
I'm using VS 2005.
When user selects a image from the FileListBox, the code is
PictureBox.ImageLocation = sFullPath
PictureBox is set to AutoSize. When the newly loaded image is smaller
than the panel size, I want to center it within the panel by
calculating and move the box to a location other than (0,0). The
problem is that when retrieving the current box size
(PictureBox.Width/Height), it returns the previously auto sized
dimensions (base on the previously loaded image). Seems like I need to
run a "wait" function to wait for the new image to be fully loaded AND
the picbox's done auto sizing to get the correct size. How do I do
that?

Jan 13 '06 #3
thanks guys but I figured it out. I put the code in
PictureBox.onLoadComplete event .. that's when the new stuff are
dupdated.

Jan 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jon Cosby | last post by:
I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this? Pen...
3
by: CroDude | last post by:
Hi all! I've made a little app that creates thumbnails and if user clicks on it, it displays the original picture in the picturebox on a panel control. In a thumbnail mouse down event I'm using...
2
by: Sharon | last post by:
I encountered a strange behavior when doing ‘new Bitmap’: The following code works fine and the given bitmap file is shown on the PictureBox (the m_DrawArea) in the correct bitmap sizes: ...
0
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for...
8
by: Lou | last post by:
I have a picture box with an image loaded into it from an Image list (Its a solid Black Image). Next I draw some lines into the picture box. The resulting image with the lines is NOT the return...
4
by: midicad2001 | last post by:
I have been researching this issue and have come across a number of solutions apparently written for VB5 or 6 and don't work under .NET, yes folks that is progress! Someone in this ng suggested...
4
by: wasishincar | last post by:
I'm trying to read a bitmap and zoom in/out it on screen. I wrote some code but it did not perform as I expect. The bitmap shift 1 pixel to the upper-left coner when zooming in/out button was...
5
by: GoGs | last post by:
How this vb6 code convert in c# dotnet2 ----- Image1.Visible = False Image1.Picture = LoadPicture("c:\image008.jpg") Dim x, y As Single x = Image1.Width y = Image1.Height Do While x...
4
by: gerardianlewis | last post by:
Any help appreciated. (VB.NET under XP and Vista, SP1 installed) My code, inherited from a VB6 version of an app that ran under W98, loads an image from a file into a PictureBox. The user may...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.