2009-12-02 5 views
1

private TableLayoutPanel CreateLayoutpan() { pTablePanel = new TableLayoutPanel(); pTablePanel.BackColor = System.Drawing.SystemColors.ButtonFace; pTablePanel.ColumnStyles.Add (새 ColumnStyle (SizeType.Absolute, 30)); pTablePanel.RowStyles.Add (새 RowStyle()); pTablePanel.Size = new System.Drawing.Size (165, 223); pTablePanel.Location = new System.Drawing.Point (9, 14); pTablePanel.TabIndex = 0; pTablePanel.Controls.Clear(); pTablePanel.ColumnCount = 2; return pTablePanel; } 여기에서 TableLayoutPanel 컨트롤을 찾으십시오.

PictureBox pict; 
      private void AddtoPbx(Image im) 
      { 
       try 
       { 
        pict = new PictureBox(); 
        pict.BackColor = System.Drawing.Color.Blue; 
        pict.Padding = new Padding(2); 

        pict.Image = m;                pict.Width = 100; 
        pict.Height = 60; 

        pict.SizeMode = PictureBoxSizeMode.StretchImage; 

        CheckBox chkBx = new CheckBox(); 
        chkBx.Name = "checkImage"; 
        chkBx.Location = new System.Drawing.Point(40, 40); 

        pTablePanel.Controls.Add(chkBx, 0, iCount); 
        pTablePanel.Controls.Add(pict, 1, iCount); 
        iCount++;      
        pTablePanel.AutoScroll = true; 
        System.Threading.Thread.Sleep(50); 
        pict.Focus(); 
        STA_gbxImages.Controls.Add(pTablePanel); 


       } 
       catch (Exception ex) 
       {  } 
      } 

내가 행에 chkbox뿐만 아니라 이미지를 추가 할 것이다 .... 지금 내 문제는 chkbox 내가 어떻게 다른 모음 ....에 ccorresponding 이미지를 추가 할 필요가 체크되어있는 경우 이 일을 도와주세요 ...

답변

0

동적 컨트롤을 만들 때 직접 폼에 추가하지 마십시오. PlaceHolder 컨트롤을 추가하고 테이블을 추가하십시오. 그런 다음 자리 표시 자에서 FinfControl()을 사용하십시오. PlaceHodler1.FindControl("table1")

관련 문제