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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. change of size of PictureBox? (error in code, or in .NET2.0?)

change of size of PictureBox? (error in code, or in .NET2.0?)

Scheduled Pinned Locked Moved C#
csharphelpwinformscomgraphics
3 Posts 2 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.
  • D Offline
    D Offline
    dorwin
    wrote on last edited by
    #1

    Hi, I have a simple project in WinForms (C# Express) .NET 2.0: vo form I have inserted panel (panel1) and in panel there is PictureBox1 Panel1 has property Dock = Fill PictureBox1 has property Dock = Top on Resize event for picturebox I have: /*----------------------------------------------------------------------*/ 1 private void pictureBox1_Resize(object sender, EventArgs e) 2 { 3 Image newImg = new Bitmap(panel1.Width ,panel1.Height ); 4 if (PictureBox1 != null) 5 { 6 if (PictureBox1.Image != null) 7 { 8 PictureBox1.Image.Dispose(); 9 PictureBox1.Image = null; 10 } 11 PictureBox1.Image = newImg; 12 } 13 } /*----------------------------------------------------------------------*/ After maximalisation of forrm has PictureBox unchanged size, although there is Dock property set to "Top". When I comment line #11, everything works fine. Why? I need to create image in PictureBox dinamically after each resizing of picturebox. However size of picturebox is not affected, and the worse it do something bad with Dock feature.. In .NET 1.1. it worked perfectly, however in .NET 2.0 it doesn't. projekt is saved here: http://www.tekl.com/testform1.zip ( has 36kb). Thank you for any help. I don't know, what to do.

    R 1 Reply Last reply
    0
    • D dorwin

      Hi, I have a simple project in WinForms (C# Express) .NET 2.0: vo form I have inserted panel (panel1) and in panel there is PictureBox1 Panel1 has property Dock = Fill PictureBox1 has property Dock = Top on Resize event for picturebox I have: /*----------------------------------------------------------------------*/ 1 private void pictureBox1_Resize(object sender, EventArgs e) 2 { 3 Image newImg = new Bitmap(panel1.Width ,panel1.Height ); 4 if (PictureBox1 != null) 5 { 6 if (PictureBox1.Image != null) 7 { 8 PictureBox1.Image.Dispose(); 9 PictureBox1.Image = null; 10 } 11 PictureBox1.Image = newImg; 12 } 13 } /*----------------------------------------------------------------------*/ After maximalisation of forrm has PictureBox unchanged size, although there is Dock property set to "Top". When I comment line #11, everything works fine. Why? I need to create image in PictureBox dinamically after each resizing of picturebox. However size of picturebox is not affected, and the worse it do something bad with Dock feature.. In .NET 1.1. it worked perfectly, however in .NET 2.0 it doesn't. projekt is saved here: http://www.tekl.com/testform1.zip ( has 36kb). Thank you for any help. I don't know, what to do.

      R Offline
      R Offline
      Robin Panther
      wrote on last edited by
      #2

      try changing pictureBox1.SizeMode property to AutoSize. While you use SizeMode=Normal, pictureBox always keeps it's starting size, unless you tell it to change it. AutoSize mode will resize pictureBox to fully show image, each time image changes. Robin Panther http://www.robinland.com

      D 1 Reply Last reply
      0
      • R Robin Panther

        try changing pictureBox1.SizeMode property to AutoSize. While you use SizeMode=Normal, pictureBox always keeps it's starting size, unless you tell it to change it. AutoSize mode will resize pictureBox to fully show image, each time image changes. Robin Panther http://www.robinland.com

        D Offline
        D Offline
        dorwin
        wrote on last edited by
        #3

        :) thank You so much! this was the reason.. SizeMode is new property in .NET 2.0 :)

        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