Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. display picturebox

display picturebox

Scheduled Pinned Locked Moved C#
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    msrezapro
    wrote on last edited by
    #1

    Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.

    private void button1_Click(object sender, EventArgs e)
    {
    PictureBox pic = new PictureBox();
    pic.Image = Image.FromFile("c:\\1.gif");
    this.Controls.Add(pic);

            for (int i = 0; i < int.MaxValue; i++)
            {
                //my work
            }
            pic.Dispose();
        }
    
    T D L 3 Replies Last reply
    0
    • M msrezapro

      Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.

      private void button1_Click(object sender, EventArgs e)
      {
      PictureBox pic = new PictureBox();
      pic.Image = Image.FromFile("c:\\1.gif");
      this.Controls.Add(pic);

              for (int i = 0; i < int.MaxValue; i++)
              {
                  //my work
              }
              pic.Dispose();
          }
      
      T Offline
      T Offline
      Tamer Oz
      wrote on last edited by
      #2

      try Application.DoEvents(); just before for iteration

      1 Reply Last reply
      0
      • M msrezapro

        Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.

        private void button1_Click(object sender, EventArgs e)
        {
        PictureBox pic = new PictureBox();
        pic.Image = Image.FromFile("c:\\1.gif");
        this.Controls.Add(pic);

                for (int i = 0; i < int.MaxValue; i++)
                {
                    //my work
                }
                pic.Dispose();
            }
        
        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        Add pic.Refresh(); after you add the control.

        It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

        1 Reply Last reply
        0
        • M msrezapro

          Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.

          private void button1_Click(object sender, EventArgs e)
          {
          PictureBox pic = new PictureBox();
          pic.Image = Image.FromFile("c:\\1.gif");
          this.Controls.Add(pic);

                  for (int i = 0; i < int.MaxValue; i++)
                  {
                      //my work
                  }
                  pic.Dispose();
              }
          
          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          msrezapro wrote:

          pic.Dispose();

          what is this? pic is a control you added to this.Controls, you can't just call Dispose() on it as it is still in use. And you should dispose of images you no longer use. Hence, if you want to remove the image, do:

          pic.Image.Dispose();
          pic.Image=null;

          if you want to remove the picturebox, do:

          this.Controls.Remove(pic);

          possibly followed by the former code. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups