Winform开发用FlowLayoutPanel控件实现HTML中DIV自由排列布局功能
#region 用FlowLayoutPanel来布局
FlowLayoutPanel flowPanel = new FlowLayoutPanel();
flowPanel.Dock = DockStyle.Fill; // 填充父容器
flowPanel.FlowDirection = FlowDirection.LeftToRight; // 从左到右排列?:ml-citation{ref="3,4" data="citationList"}
flowPanel.WrapContents = true;
panel1.Controls.Add(flowPanel);
panel1.BackColor = Color.Red;
if (ds.Tables.Count > 0)
{
_dt = ds.Tables[0];
int dtRows = _dt.Rows.Count;
if (dtRows > 0)
{
for (int i = 0; i < dtRows; i++)
{
byte[] bytes = (byte[])_dt.Rows[i]["image"];
PictureBox pic = new PictureBox();
pic.Size = new Size(200, 200);
using (MemoryStream ms = new MemoryStream(bytes))
{
Image img = Image.FromStream(ms);
Bitmap bit = new Bitmap(img, 200, 200);
pic.Image = bit;
flowPanel.Controls.Add(pic);
}
}
}
panel1.Controls.Add(flowPanel);
}
#endregion
查看更多关于Winform开发用FlowLayoutPanel控件实现HTML中DIV自由排列布局功能的详细内容...