473,386 Members | 1,745 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.

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 "ImageChanged" type event so I can't watch for that.

Here's the code where it changes:

private void lstAds_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (adComponents ad in clsock.adList.Keys)
{
if (lstAds.FocusedItem.SubItems[1].Text ==
ad.description)
{
if (ad.hasPic)
pbxPreview.ImageLocation = ad.picLink;
else
pbxPreview.Image =
Image.FromStream(
this.GetType().Assembly.GetManifestResourceStream(
"creader.Resources.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 2015
On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmail.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*********@nnowslpianmk.comwrote:
>On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmail.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*********@nnowslpianmk.comwrote:
>On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <re*******@gmail.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
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...
5
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...
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...
3
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...
1
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...
2
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...
5
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...
1
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.