2011-12-28 1 views
0

c를 windowsform에있는 PictureBox를 추가하지만 이미지가 attachimage를로드 한 후 양식에 표시되지 않은 내가 도구 상자에서내가로드 이벤트 핸들러에 windowsform에있는 PictureBox를 추가하려고 #

(안 C#을에 의해)을 추가 된 PictureBox를이다
private void ViewCmap_Load(object sender, EventArgs e) 
     { 
      for (int i = 0; i < ConceptProperties.ConceptsMap.Count; i++) 
      { 
       conceptattchboxlist.Add(new PictureBox()); 
       conceptattchboxlist[i].Visible = true; 
       if (ConceptProperties.ConceptsMap[i].Attachments.Count > 0) 
       { 
        PictureBox new_attach_box = new PictureBox(); 
        new_attach_box.Image = attachimage.Image; 
        new_attach_box.Width = attachimage.Width; 
        new_attach_box.Height = attachimage.Height; 
        new_attach_box.BackgroundImageLayout = ImageLayout.Stretch; 
        new_attach_box.SizeMode = PictureBoxSizeMode.StretchImage; 
        new_attach_box.Location = new Point(ConceptProperties.ConceptsMap[i].Coords[0] + (ConceptProperties.ConceptsMap[i].Coords[2]), ConceptProperties.ConceptsMap[i].Coords[1] + (ConceptProperties.ConceptsMap[i].Coords[3])); 
        conceptattchboxlist[i] = new_attach_box; 
       } 
      } 
      for (int i = 0; i < ConceptProperties.ConnectionMap.Count; i++) 
      { 
       connectionattchboxlist.Add(new PictureBox()); 
       connectionattchboxlist[i].Visible = true; 
       if (ConceptProperties.ConnectionMap[i].Attachments.Count > 0) 
       { 
        PictureBox new_attach_box = new PictureBox(); 
        new_attach_box.Image = attachimage.Image; 
        new_attach_box.Width = attachimage.Width; 
        new_attach_box.Height = attachimage.Height; 
        new_attach_box.BackgroundImageLayout = ImageLayout.Stretch; 
        new_attach_box.SizeMode = PictureBoxSizeMode.StretchImage; 
        new_attach_box.Location = new Point(ConceptProperties.ConceptsMap[i].Coords[0] + (ConceptProperties.ConceptsMap[i].Coords[2]), ConceptProperties.ConceptsMap[i].Coords[1] + (ConceptProperties.ConceptsMap[i].Coords[3])); 
        new_attach_box.Show(); 
        connectionattchboxlist[i] = new_attach_box; 
       } 
      } 
     } 
+0

루프 드 루프를! – Yuck

+0

새로운 PictureBox를 폼에 추가하려면'this.Controls.Add (new_attach_box)'를 사용하십시오. 그런데 왜 두 개의 동일한 루프를하고 있습니까? – keyboardP

답변

3

가있는 PictureBox 또는 제어 사용을 추가하려면 :

PictureBox pic = new Picturebox(); 
this.Controls.Add(pic); 
+0

감사합니다. – kartal

관련 문제