2009-12-02 4 views
1

private TableLayoutPanel CreateLayoutpan() { pTablePanel = new TableLayoutPanel(); pTablePanel.BackColor = System.Drawing.SystemColors.ButtonFace; pTablePanel.ColumnStyles.Add (nouveau ColumnStyle (SizeType.Absolute, 30)); pTablePanel.RowStyles.Add (nouveau 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; }rechercher des contrôles dans 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) 
       {  } 
      } 

ici, je vais ajouter chkbox ainsi que l'image de suite .... maintenant mon problème est de savoir si la chkbox est cochée je dois ajouter une image de ccorresponding dans d'autres collection .... comment Pour ce faire, aidez-moi ...

Répondre

0

Lors de la création de contrôles dynamiques, ne les ajoutez pas directement au formulaire. Mettez juste un contrôle PlaceHolder et ajoutez votre table à lui. Puis, utilisez FinfControl() de votre espace réservé: PlaceHodler1.FindControl("table1")

Questions connexes