|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get PictureBox with x height returned size of previously loaded imageI'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? I haven't tested this, but what if you do "Application.DoEvents" after
setting the ImageLocation? Then does it return the correct size? Show quoteHide quote "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? > > 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? -- Show quoteHide quoteBest 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:1137086164.777883.209110@g49g2000cwa.googlegroups.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? > thanks guys but I figured it out. I put the code in
PictureBox.onLoadComplete event .. that's when the new stuff are dupdated. |
|||||||||||||||||||||||