【问题标题】:find controls in TableLayoutPanel在 TableLayoutPanel 中查找控件
【发布时间】:2009-12-02 16:59:10
【问题描述】:

私有 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; 返回pTablePanel; }

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,我需要在其他集合中添加相应的图像......如何做到这一点请帮助我......

【问题讨论】:

    标签: c#


    【解决方案1】:

    创建动态控件时,不要直接将它们添加到表单中。只需放置一个 PlaceHolder 控件并将您的表格添加到其中。 然后,使用占位符中的 FinfControl():PlaceHodler1.FindControl("table1")

    【讨论】:

      猜你喜欢
      • 2012-09-29
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多