2009-12-02 55 views
1

private TableLayoutPanel CreateLayoutpan() pTablePanel = new TableLayoutPanel(); pTablePanel.BackColor = System.Drawing.SystemColors.ButtonFace; pTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute,30)); pTablePanel.RowStyles.Add(new 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")

相關問題