如何在 TabPage 中添加 FlowLayoutPanel 和 PictureBox?
How can I add FlowLayoutPanel and PictureBox in TabPage?
如何在tab页添加flowlayout面板和picturebox?
我想将所有图片网址添加到图片框和图片框列表中,添加到流布局并添加到标签页:
这是我的代码
List<FlowLayoutPanel> flows = new List<FlowLayoutPanel>();
FlowLayoutPanel flow = new FlowLayoutPanel();
List<TabPage> tp = new List<TabPage>();
foreach (var item in edu.data)
{
flow.BackColor = Color.DarkGray;
flow.Dock = DockStyle.Fill;
flow.Tag = item.content;
flow.AutoScroll = true;
flow.Name = item.category;
foreach (var item2 in item.content)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(170, 130);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.LoadAsync("https://ytimg.googleusercontent.com/vi/" + item2.urlYutub.Split('=')[1] + "/hqdefault.jpg");
flow.Controls.Add(pb);
}
flows.Add(flow);
}
foreach (var flo in flows)
{
TabPage tp2 = new TabPage();
tp2.Text = flo.Name;
tp2.Controls.Add(flo);
tp.Add(tp2);
}
for (int index = 0; index < tp.Count; index++)
{
tabEducation.TabPages.Add(tp[index]);
}
试试这个
foreach (var item in edu.data)
{
FlowLayoutPanel flow = new FlowLayoutPanel();
flow.BackColor = Color.DarkGray;
flow.Dock = DockStyle.Fill;
flow.Tag = item.content;
flow.AutoScroll = true;
flow.Name = item.category;
foreach (var item2 in item.content)
{
if (item.category == flow.Name)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(170, 130);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.LoadAsync("https://ytimg.googleusercontent.com/vi/" + item2.urlYutub.Split('=')[1] + "/hqdefault.jpg");
flow.Controls.Add(pb);
}
}
TabPage tp = new TabPage();
tp.Text = flow.Name;
tp.Controls.Add(flow);
tabEducation.TabPages.Add(tp);
}
如何在tab页添加flowlayout面板和picturebox? 我想将所有图片网址添加到图片框和图片框列表中,添加到流布局并添加到标签页:
这是我的代码
List<FlowLayoutPanel> flows = new List<FlowLayoutPanel>();
FlowLayoutPanel flow = new FlowLayoutPanel();
List<TabPage> tp = new List<TabPage>();
foreach (var item in edu.data)
{
flow.BackColor = Color.DarkGray;
flow.Dock = DockStyle.Fill;
flow.Tag = item.content;
flow.AutoScroll = true;
flow.Name = item.category;
foreach (var item2 in item.content)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(170, 130);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.LoadAsync("https://ytimg.googleusercontent.com/vi/" + item2.urlYutub.Split('=')[1] + "/hqdefault.jpg");
flow.Controls.Add(pb);
}
flows.Add(flow);
}
foreach (var flo in flows)
{
TabPage tp2 = new TabPage();
tp2.Text = flo.Name;
tp2.Controls.Add(flo);
tp.Add(tp2);
}
for (int index = 0; index < tp.Count; index++)
{
tabEducation.TabPages.Add(tp[index]);
}
试试这个
foreach (var item in edu.data)
{
FlowLayoutPanel flow = new FlowLayoutPanel();
flow.BackColor = Color.DarkGray;
flow.Dock = DockStyle.Fill;
flow.Tag = item.content;
flow.AutoScroll = true;
flow.Name = item.category;
foreach (var item2 in item.content)
{
if (item.category == flow.Name)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(170, 130);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.LoadAsync("https://ytimg.googleusercontent.com/vi/" + item2.urlYutub.Split('=')[1] + "/hqdefault.jpg");
flow.Controls.Add(pb);
}
}
TabPage tp = new TabPage();
tp.Text = flow.Name;
tp.Controls.Add(flow);
tabEducation.TabPages.Add(tp);
}