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. Loop

Loop

Scheduled Pinned Locked Moved C#
4 Posts 3 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.
  • S Offline
    S Offline
    shamsteady
    wrote on last edited by
    #1

    I had write this code for (int i = 0; i < totalEquipment; i++) try { for (int j = 0; j < sEquip[index].index; j++) { try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { xPosition += length; } } } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { yPosition -= range; } } } The problem is this part which it keep add panel to window form without stoping like non stop looping. How can i stop this error? try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... }

    G C 2 Replies Last reply
    0
    • S shamsteady

      I had write this code for (int i = 0; i < totalEquipment; i++) try { for (int j = 0; j < sEquip[index].index; j++) { try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { xPosition += length; } } } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { yPosition -= range; } } } The problem is this part which it keep add panel to window form without stoping like non stop looping. How can i stop this error? try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... }

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      There is nothing in that code that would create a loop. I assume that ... means that there are more code in the block, what does that code contain?

      --- single minded; short sighted; long gone;

      S 1 Reply Last reply
      0
      • G Guffa

        There is nothing in that code that would create a loop. I assume that ... means that there are more code in the block, what does that code contain?

        --- single minded; short sighted; long gone;

        S Offline
        S Offline
        shamsteady
        wrote on last edited by
        #3

        The code contain an array of panel that will be add to window form. It will be display according to the number of input. The problem is the panel will be display but it keep blinking during runtime meaning that it generate too many panel...

        1 Reply Last reply
        0
        • S shamsteady

          I had write this code for (int i = 0; i < totalEquipment; i++) try { for (int j = 0; j < sEquip[index].index; j++) { try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { xPosition += length; } } } catch (Exception ex) { throw new Exception(ex.Message + " " + ex.StackTrace); } finally { yPosition -= range; } } } The problem is this part which it keep add panel to window form without stoping like non stop looping. How can i stop this error? try { ... bar[j].Size = new Size(length,20); bar[j].BackColor = System.Drawing.Color.Blue; bar[j].Location = new Point(xPosition,yPosition); this.Controls.Add(bar[j]); ... }

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Why all the try statements ? You need to step through the code to see what is going on.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          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