473,796 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PictureBox reverts to previously selected image

I'm having an issue that I can't quite figure out. I have a
PictureBox that initially sets a picture from an embedded resource.
The user clicks a listview item and if an image url is available, it
sets the ImageLocation property to the url of the image and loads it.
Then if the user clicks a ListView item without an image url, the
default embedded image is displayed. This all works great, but if I
click an item with an image url, then one without, after a second the
previous image is displayed, replacing the default. I've run it
through a debugger and it doesn't catch where the change is happening,
I only set the image twice in my code from one method, once to set the
image from a URL, once to set it from the resources. Debugging
doesn't pick up where it gets reverted back and I don't know where to
look. There's no "ImageChang ed" type event so I can't watch for that.

Here's the code where it changes:

private void lstAds_Selected IndexChanged(ob ject sender, EventArgs e)
{
foreach (adComponents ad in clsock.adList.K eys)
{
if (lstAds.Focused Item.SubItems[1].Text ==
ad.description)
{
if (ad.hasPic)
pbxPreview.Imag eLocation = ad.picLink;
else
pbxPreview.Imag e =
Image.FromStrea m(
this.GetType(). Assembly.GetMan ifestResourceSt ream(
"creader.Resour ces.noimg.png") );
break;
}
}
}

I really don't know what to do now. If you need any other info, let
me know.

Thanks,
Brandon

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
Jul 17 '08 #1
3 2034
On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmai l.com>
wrote:
I'm having an issue that I can't quite figure out. I have a
PictureBox that initially sets a picture from an embedded resource.
The user clicks a listview item and if an image url is available, it
sets the ImageLocation property to the url of the image and loads it.
Then if the user clicks a ListView item without an image url, the
default embedded image is displayed. This all works great, but if I
click an item with an image url, then one without, after a second the
previous image is displayed, replacing the default.
Have you tried setting the ImageLocation property back to null when you
set an Image explicitly?

Pete
Jul 17 '08 #2
On Thu, 17 Jul 2008 14:49:57 -0700, "Peter Duniho"
<Np*********@nn owslpianmk.comw rote:
>On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmai l.com>
wrote:
>I'm having an issue that I can't quite figure out. I have a
PictureBox that initially sets a picture from an embedded resource.
The user clicks a listview item and if an image url is available, it
sets the ImageLocation property to the url of the image and loads it.
Then if the user clicks a ListView item without an image url, the
default embedded image is displayed. This all works great, but if I
click an item with an image url, then one without, after a second the
previous image is displayed, replacing the default.

Have you tried setting the ImageLocation property back to null when you
set an Image explicitly?

Pete

No, but that sounds like a good idea, i'll try that and get back.

Thanks,
Brandon

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
Jul 18 '08 #3
On Thu, 17 Jul 2008 14:49:57 -0700, "Peter Duniho"
<Np*********@nn owslpianmk.comw rote:
>On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmai l.com>
wrote:
>I'm having an issue that I can't quite figure out. I have a
PictureBox that initially sets a picture from an embedded resource.
The user clicks a listview item and if an image url is available, it
sets the ImageLocation property to the url of the image and loads it.
Then if the user clicks a ListView item without an image url, the
default embedded image is displayed. This all works great, but if I
click an item with an image url, then one without, after a second the
previous image is displayed, replacing the default.

Have you tried setting the ImageLocation property back to null when you
set an Image explicitly?

Pete

That worked great, thanks!

Brandon

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
Jul 18 '08 #4

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

Similar topics

8
31539
by: Pavan Arise | last post by:
Dear all.. I have a picturebox filled on a form. The picturebox has some graphics displayed on it.I was trying to save the picturebox, but continuesly failed to do so. I am clueless of why it is happening. I tried to save the image of the form & also the picturebox, but always, i see a blank file saved. Is there a way to save whatever is displayed on the picturebox, to a file?? Thanks for any suggestions and help. Regards,
5
4904
by: BrianW | last post by:
I am working on a program that has multiple picturebox controls that a user is allowed to move around which are contained within a panel control for visual placement. In my mousedown event, I set the picturebox control's borderstyle to Fixed3D, but upon doing so, I am not able to track the picturebox control through mousemove events (if you move the mouse off of the control too quickly, the control no longer receives mouse events). If I...
8
2401
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 value of PictureBox1.Image???? In the exapmle below control "D" shows only the picture(Black Image) without the lines I added using the brush? The Picturebox shows the lines nicely but the lines don't seem to be part of the controls "Inage"...
3
4093
by: tedqn | last post by:
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
1
2500
by: ray well | last post by:
hi, i need to give the user the ability to extract a rectangular area of their choice from a graphic displayed in a picture box to the clipboard, so they can use it elsewhere. say the graphic has an image of a house with a door in it and the user is interested in the door. the rectangle is selected by placing the mouse on the upper left corner of the door, pressing down on the left mouse button, and draging it to the lower right...
2
4444
by: Christie | last post by:
In my application, lines (shapes such as circles) and text are drawn in a picturebox. I am struggling to find a way to print the text and shapes. There is no images in the picturebox. Could someone please show me the way. I am using Visual Studio 2005 (VB.Net) Operating System: XP Pro Thanks
5
7787
by: Fao, Sean | last post by:
I'm working on a Windows application (VS 2005) that I will need to be able to select images I've added to a FlowLayoutPannel. I was attempting to select the various PictureBoxes and noticed that it wasn't working. Reading through the MSDN to find out why, I ran across the following: "The PictureBox is not a selectable control, which means that it cannot receive input focus." This obviously puts a damper on the project. Is there any...
1
6552
by: jimwawar | last post by:
I am working in C# and have a windows form containing a picturebox. The picture box is loaded with a bitmap by the user. The bitmaps are larger then the window and require scrolling. There is an option to overlay a grid on the bitmap. If the grid has been selected it appears over the image. If the scroll bar buttons are used to view the rest of the image the grid remains visible. If the mouse is clicked in the scroll bar to move to a different...
2
2087
Atran
by: Atran | last post by:
Hello everybody, how I can edit the picturebox image? I want to edit the image using something like "magic wand tool". "Magic Wand Tool" is a tool in photoshop, this tool takes a part of the image I selected, then I save the part selected to a file (image file)............ -------------------------------------------------------------------------------------------------- If you cant do that way, try to draw a simple line on the image, after...
0
9683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10231
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.