.NET的winform中listview的绑定
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:35 点击:次
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);
{
// 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);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>