代码添加控件-从数据库提取数据
时间:2021-07-01 10:21:17
帮助过:4人阅读
4.里面的FlowLayoutPanel,设置它Dock=Top,AutoSize=true
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using data;
using dataDA;
namespace pp
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
LD();
}
private void LD()
{
List<CarData> list = new CarDA().Select();
foreach (CarData data in list)
{
CheckBox cb = new CheckBox();
cb.Text = data.Name;
cb.Tag = data.Code;
cb.Width = 200;
flowLayoutPanel1.Controls.Add(cb);
}
}
}
}
代码添加控件-从数据库提取数据
标签: