我想在特定记录的列表视图中显示图片框控件和标签。所有记录都来自数据库。我尝试了但是我只能显示单个图像,但我想显示带有标签的所有图像 我尝试的代码是
DataSet ds3 = load.LoadNewlyAddedBook();
DataTable dt3 = ds3.Tables[0];
lstViewNewAdd.Items.Clear();
int count = dt3.Rows.Count;
for (int a = 0; a < count; a++)
{
DataRow dtRow = dt3.Rows[a];
if (dtRow.RowState != DataRowState.Deleted)
{
ListViewItem lvi3 = new ListViewItem(dtRow["BookName"].ToString());
PictureBox p1 = new PictureBox();
p1.Size = new Size(80, 100);
Byte[] bytes = (Byte[])(dtRow["BookImage"]);
MemoryStream ms = new MemoryStream(bytes);
p1.Image = Image.FromStream(ms);
p1.SizeMode = PictureBoxSizeMode.StretchImage;
Label lbl = new Label();
lbl.Text = dtRow["BookName"].ToString();
lstViewNewAdd.Controls.Add(p1);
//lstViewNewAdd.Controls.Add(lbl);
//lvi3.SubItems.Add(p1);
//lstViewNewAdd.Items.Add(lvi3);
}
}
请建议我任何解决方案。 提前谢谢。
答案 0 :(得分:0)