winform中listview的绑定

 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);
            }
        }

上一篇:Android 如何通过Intent在activity之间传递自定义对象


下一篇:Enum 绑定到 CheckBox