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. Why doesnt this function for controls objects work? [modified]

Why doesnt this function for controls objects work? [modified]

Scheduled Pinned Locked Moved C#
graphicshelptutorialquestion
9 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
    Matjaz xyz
    wrote on last edited by
    #1

    Where's the problem? I have thre listboxes. For example, the first one has 23 image paths, the second one has 7 imagepaths. First i check if any of them are the same then i add them to the third lsitbox. Then i want to create pictureboxes depending of the number of items in the third listbox. Here's the code of the function: void prikaz(int stevilo) { PictureBox[] picBOX = new PictureBox[stevilo]; CheckBox[] chkBOX = new CheckBox[stevilo]; for(int i = 0; i<lb1.items.count;> { Image a; Image b; a = System.Drawing.Image.FromFile(@txtNacrti.Text + @"\" + lb1.Items[i].ToString()); //b = new Bitmap(a, 100, 100); picBOX[i] = new PictureBox(); picBOX[i].Size = new Size(100, 100); picBOX[i].Name = "picc" + i.ToString(); picBOX[i].Location = new System.Drawing.Point(picX, picY); picBOX[i].BorderStyle = BorderStyle.FixedSingle; picBOX[i].ImageLocation = @txtNacrti.Text + @"\" + lb1.Items[i].ToString(); chkBOX[i] = new CheckBox(); chkBOX[i].AutoSize = true; chkBOX[i].Name = "chk" + i.ToString(); chkBOX[i].Location = new System.Drawing.Point(chkX, chkY); chkBOX[i].Text = lb1.Items[i].ToString(); chkY = chkY + 106; picY = picY + 106; } }

    Regards, Matjaž

    modified on Thursday, November 27, 2008 8:17 AM

    L T 3 Replies Last reply
    0
    • M Matjaz xyz

      Where's the problem? I have thre listboxes. For example, the first one has 23 image paths, the second one has 7 imagepaths. First i check if any of them are the same then i add them to the third lsitbox. Then i want to create pictureboxes depending of the number of items in the third listbox. Here's the code of the function: void prikaz(int stevilo) { PictureBox[] picBOX = new PictureBox[stevilo]; CheckBox[] chkBOX = new CheckBox[stevilo]; for(int i = 0; i<lb1.items.count;> { Image a; Image b; a = System.Drawing.Image.FromFile(@txtNacrti.Text + @"\" + lb1.Items[i].ToString()); //b = new Bitmap(a, 100, 100); picBOX[i] = new PictureBox(); picBOX[i].Size = new Size(100, 100); picBOX[i].Name = "picc" + i.ToString(); picBOX[i].Location = new System.Drawing.Point(picX, picY); picBOX[i].BorderStyle = BorderStyle.FixedSingle; picBOX[i].ImageLocation = @txtNacrti.Text + @"\" + lb1.Items[i].ToString(); chkBOX[i] = new CheckBox(); chkBOX[i].AutoSize = true; chkBOX[i].Name = "chk" + i.ToString(); chkBOX[i].Location = new System.Drawing.Point(chkX, chkY); chkBOX[i].Text = lb1.Items[i].ToString(); chkY = chkY + 106; picY = picY + 106; } }

      Regards, Matjaž

      modified on Thursday, November 27, 2008 8:17 AM

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Matjaž Grahek wrote:

      Where's the problem?

      Yes, can you please tell us what the problem is?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 beta 1 - out now!
      ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

      M 1 Reply Last reply
      0
      • M Matjaz xyz

        Where's the problem? I have thre listboxes. For example, the first one has 23 image paths, the second one has 7 imagepaths. First i check if any of them are the same then i add them to the third lsitbox. Then i want to create pictureboxes depending of the number of items in the third listbox. Here's the code of the function: void prikaz(int stevilo) { PictureBox[] picBOX = new PictureBox[stevilo]; CheckBox[] chkBOX = new CheckBox[stevilo]; for(int i = 0; i<lb1.items.count;> { Image a; Image b; a = System.Drawing.Image.FromFile(@txtNacrti.Text + @"\" + lb1.Items[i].ToString()); //b = new Bitmap(a, 100, 100); picBOX[i] = new PictureBox(); picBOX[i].Size = new Size(100, 100); picBOX[i].Name = "picc" + i.ToString(); picBOX[i].Location = new System.Drawing.Point(picX, picY); picBOX[i].BorderStyle = BorderStyle.FixedSingle; picBOX[i].ImageLocation = @txtNacrti.Text + @"\" + lb1.Items[i].ToString(); chkBOX[i] = new CheckBox(); chkBOX[i].AutoSize = true; chkBOX[i].Name = "chk" + i.ToString(); chkBOX[i].Location = new System.Drawing.Point(chkX, chkY); chkBOX[i].Text = lb1.Items[i].ToString(); chkY = chkY + 106; picY = picY + 106; } }

        Regards, Matjaž

        modified on Thursday, November 27, 2008 8:17 AM

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        You are creating Controls, but I do not see you adding them to any container.

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 beta 1 - out now!
        ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

        M 2 Replies Last reply
        0
        • L leppie

          Matjaž Grahek wrote:

          Where's the problem?

          Yes, can you please tell us what the problem is?

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 beta 1 - out now!
          ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

          M Offline
          M Offline
          Matjaz xyz
          wrote on last edited by
          #4

          :D Nothing happens, thats the problem.

          Regards, Matjaž

          1 Reply Last reply
          0
          • L leppie

            You are creating Controls, but I do not see you adding them to any container.

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 beta 1 - out now!
            ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

            M Offline
            M Offline
            Matjaz xyz
            wrote on last edited by
            #5

            Hmm... how does that go?

            Regards, Matjaž

            T 1 Reply Last reply
            0
            • L leppie

              You are creating Controls, but I do not see you adding them to any container.

              xacc.ide - now with TabsToSpaces support
              IronScheme - 1.0 beta 1 - out now!
              ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

              M Offline
              M Offline
              Matjaz xyz
              wrote on last edited by
              #6

              OK, Just got it ;) Thanks!

              Regards, Matjaž

              1 Reply Last reply
              0
              • M Matjaz xyz

                Hmm... how does that go?

                Regards, Matjaž

                T Offline
                T Offline
                Tom Deketelaere
                wrote on last edited by
                #7

                me.controls.add('yourcontrol') or if in panel panelname.controls.add('yourcontrol') or ... any container control should have the controls methode use that to add them

                M 1 Reply Last reply
                0
                • T Tom Deketelaere

                  me.controls.add('yourcontrol') or if in panel panelname.controls.add('yourcontrol') or ... any container control should have the controls methode use that to add them

                  M Offline
                  M Offline
                  Matjaz xyz
                  wrote on last edited by
                  #8

                  yeah :) OR this.Controls.Add(control) Thanks to u too :)

                  Regards, Matjaž

                  1 Reply Last reply
                  0
                  • M Matjaz xyz

                    Where's the problem? I have thre listboxes. For example, the first one has 23 image paths, the second one has 7 imagepaths. First i check if any of them are the same then i add them to the third lsitbox. Then i want to create pictureboxes depending of the number of items in the third listbox. Here's the code of the function: void prikaz(int stevilo) { PictureBox[] picBOX = new PictureBox[stevilo]; CheckBox[] chkBOX = new CheckBox[stevilo]; for(int i = 0; i<lb1.items.count;> { Image a; Image b; a = System.Drawing.Image.FromFile(@txtNacrti.Text + @"\" + lb1.Items[i].ToString()); //b = new Bitmap(a, 100, 100); picBOX[i] = new PictureBox(); picBOX[i].Size = new Size(100, 100); picBOX[i].Name = "picc" + i.ToString(); picBOX[i].Location = new System.Drawing.Point(picX, picY); picBOX[i].BorderStyle = BorderStyle.FixedSingle; picBOX[i].ImageLocation = @txtNacrti.Text + @"\" + lb1.Items[i].ToString(); chkBOX[i] = new CheckBox(); chkBOX[i].AutoSize = true; chkBOX[i].Name = "chk" + i.ToString(); chkBOX[i].Location = new System.Drawing.Point(chkX, chkY); chkBOX[i].Text = lb1.Items[i].ToString(); chkY = chkY + 106; picY = picY + 106; } }

                    Regards, Matjaž

                    modified on Thursday, November 27, 2008 8:17 AM

                    T Offline
                    T Offline
                    Thomas Weller 0
                    wrote on last edited by
                    #9

                    When this is all the code that runs, then the controls won't belong to any parent (form or group box or something) - and consequently will not show up on the screen, since they are not part of any container control. There must be something like Form.Controls.Add(pic/checkBox[i]) for every control. Regards Thomas

                    www.thomas-weller.de Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
                    Programmer - an organism that turns coffee into software.

                    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