PictureBox reverts to previously selected image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brandon Arnold

    #1

    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
    ----------------------------------------------------------
    Best Usenet Service Providers 2026 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

  • Peter Duniho

    #2
    Re: PictureBox reverts to previously selected image

    On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <reasonman@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

    Comment

    • Brandon Arnold

      #3
      Re: PictureBox reverts to previously selected image

      On Thu, 17 Jul 2008 14:49:57 -0700, "Peter Duniho"
      <NpOeStPeAdM@nn owslpianmk.comw rote:
      >On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <reasonman@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
      ----------------------------------------------------------
      Best Usenet Service Providers 2026 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

      Comment

      • Brandon Arnold

        #4
        Re: PictureBox reverts to previously selected image

        On Thu, 17 Jul 2008 14:49:57 -0700, "Peter Duniho"
        <NpOeStPeAdM@nn owslpianmk.comw rote:
        >On Thu, 17 Jul 2008 08:58:53 -0700, Brandon Arnold <reasonman@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
        ----------------------------------------------------------
        Best Usenet Service Providers 2026 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

        Comment

        Working...