Why doesnt this function for controls objects work? [modified]
-
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
-
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
-
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
-
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)):D Nothing happens, thats the problem.
Regards, Matjaž
-
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))Hmm... how does that go?
Regards, Matjaž
-
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))OK, Just got it ;) Thanks!
Regards, Matjaž
-
Hmm... how does that go?
Regards, Matjaž
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
-
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
yeah :) OR this.Controls.Add(control) Thanks to u too :)
Regards, Matjaž
-
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
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 Thomaswww.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.