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; }
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)
{ }
}
here i ll add chkbox as well as image in a row.... now my problem is if the chkbox is checked i need to add ccorresponding image in other collection .... how to do this please help me...
When creating dynamic controls, don't add them to the form directly. Just put a PlaceHolder control and add your table to it. Then, use FinfControl() from your Placeholder: PlaceHodler1.FindControl("table1")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.