111,098
社区成员




foreach (Control c in tableLayoutPanel1.Controls)
{
Panel panel=(Panel)c;
foreach (Control dc in panel.Controls)
{
dc.Dispose();
}
c.Dispose();
}
//用n遍历数据集循环加到tableLayoutPanel上
DataRow row = insectTable.Rows[n];//数据集中的一条记录
string insect_no = row["insect_no"].ToString();
DataRow mainPicRow = this.accessDb.getMainPicRow(insect_no);
//其中的几个字段
string insectName = row["name"].ToString();
string part = row["part"].ToString();
string picPath="";
string description = "";
PictureBox pictrueBox = new PictureBox();
pictrueBox.ImageLocation = Application.StartupPath+"\\"+ picPath;
pictrueBox.SizeMode = PictureBoxSizeMode.Zoom;
pictrueBox.Size = new Size(275, 177);
pictrueBox.Dock = DockStyle.Top;
pictrueBox.Location = new System.Drawing.Point(5, 5);
pictrueBox.Click+=new EventHandler(pictrueBox_Click);
pictrueBox.MouseMove+=new MouseEventHandler(pictrueBox_MouseMove);
toolTip1.SetToolTip(pictrueBox, description);
Label lblName = new Label();
lblName.AutoSize = true;
lblName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
lblName.Location = new System.Drawing.Point(20, 191);
lblName.Name = "label1" + n;
lblName.Size = new System.Drawing.Size(56, 16);
lblName.Text = "名称:" + insectName;
Label lblPart = new Label();
lblPart.AutoSize = true;
lblPart.ForeColor = System.Drawing.Color.Blue;
lblPart.Location = new System.Drawing.Point(20, 214);
lblPart.Name = "label2" + n;
lblPart.Size = new System.Drawing.Size(41, 12);
lblPart.Text = "发病部位:" + part.Replace(",", ",");
Button button = new Button();
button.Text = "查看详细";
button.Location = new System.Drawing.Point(197, 200);
button.Size = new Size(75, 23);
button.Tag = n;
button.Click += new System.EventHandler(this.showDetail_Click);
Panel panel = new Panel();
panel.BorderStyle = BorderStyle.FixedSingle;
panel.Size = new Size(303, 260);
panel.Padding = new Padding(10, 10, 10, 10);
panel.Controls.Add(pictrueBox);
panel.Controls.Add(button);
panel.Controls.Add(lblName);
panel.Controls.Add(lblPart);
this.tableLayoutPanel1.Controls.Add(panel);