Listview控件添加数据问题

zhou44871 2010-09-13 12:50:19
本人C#初学者,现在还没学数据库,怎么把ArrayList里面的学生信息添加到视图Details里面
...全文
170 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhou44871 2010-09-13
  • 打赏
  • 举报
回复
怎么样把我保存在集合Arraylist里面的信息添加到listview里面啊
zjx198934 2010-09-13
  • 打赏
  • 举报
回复
没弄明白LZ的意思!
li12403074 2010-09-13
  • 打赏
  • 举报
回复
也不说详细点,要改视图的话,就在数据库中修改,数据库中有相应的功能给你改的,完了保存就好了。
明哥说编程 2010-09-13
  • 打赏
  • 举报
回复
可以使用for 循环

for(int i=0;i<Arraylist.count;i++)
{
ListViewItem lvi=new ListViewItem(Arraylist[i]);
ListView.Add.Item(lvi);
}
亲爱的-爹爹 2010-09-13
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
ArrayList list = new ArrayList();
list.Add(new Student("Tom", "荆州", 18));
list.Add(new Student("san", "天门", 18));
list.Add(new Student("ann", "仙桃", 18));
list.Add(new Student("jack", "公安", 18));
foreach (Student stu in list)
{
ListViewItem item = new ListViewItem(stu.Name);
item.SubItems.Add(stu.Address);
item.SubItems.Add(stu.Age.ToString());
listView1.Items.Add(item);
}
}
}
class Student
{
public Student()
{

}
public Student(String name, String address, int age)
{
this.name = name;
this.address = address;
this.age = age;
}
private String name;

public String Name
{
get { return name; }
set { name = value; }
}
private String address;

public String Address
{
get { return address; }
set { address = value; }
}
private int age;

public int Age
{
get { return age; }
set { age = value; }
}
}
}
denbes 2010-09-13
  • 打赏
  • 举报
回复
ListView lv = new ListView();
//添加一行的方法
ListViewItem item = lv.Items.Add("第一行的第一列");
item.SubItems.Add("第一行的第二列");
item.SubItems.Add("第一行的第三列");
denbes 2010-09-13
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20100716/11/509a1a4f-a690-4d52-9742-74f86dd9956d.html
sainmars 2010-09-13
  • 打赏
  • 举报
回复
简单来说就是:
for(int i=0;i<Arraylist对象.count;i++)
{
ListViewItem lvi=new ListViewItem(列表的项);
lvi.SubItems.AddRanage(子项);
ListView.Add.Item(lvi);
}
不过我没做拆箱
  • 打赏
  • 举报
回复
遍历、
sainmars 2010-09-13
  • 打赏
  • 举报
回复
首先遍历Arraylist集合
添加listviewItem对象
将Arraylist集合添加到listviewItem对象
完成

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧