您的位置首页生活快答

在winform中listView1怎么绑定数据库

在winform中listView1怎么绑定数据库

的有关信息介绍如下:

在winform中listView1怎么绑定数据库

private void FrmXMLShow_Load(object sender, EventArgs e)

{

// listview样式设置

listView1.GridLines = true;

listView1.FullRowSelect = true;

listView1.View = View.Details;

listView1.Scrollable = false;

listView1.MultiSelect = false;

listView1.HeaderStyle = ColumnHeaderStyle.Clickable;

// 表头设置

listView1.Columns.Add("ID", 50, HorizontalAlignment.Center);

listView1.Columns.Add("姓名", 50, HorizontalAlignment.Center);

listView1.Columns.Add("性别", 50, HorizontalAlignment.Center);

listView1.Columns.Add("年龄", 50, HorizontalAlignment.Center);

listView1.Columns.Add("学校", 150, HorizontalAlignment.Center);

listView1.Columns.Add("联系电话", 150, HorizontalAlignment.Center);

foreach (Information i in ixs.ReadAllInformation())

{

ListViewItem item = new ListViewItem();

item.SubItems.Clear();

item.Text = i.Id;

item.SubItems.Add(i.Name);

item.SubItems.Add(i.Gender);

item.SubItems.Add(i.Age.ToString());

item.SubItems.Add(i.University);

item.SubItems.Add(i.Phone);

listView1.Items.Add(item);

}

}