标签:window form bubuko obj oid image item tostring clear
实现效果:
知识运用
ListView控件的GridLines //设置是否在ListView控件中显示网格线
public bool GridLines{get;set}
和CheckBoxes属性 //设置listView控件中各数据项是否显示复选框
public bool CheckBoxes{get;set}
以及ListViewItem数据项的Checked属性 //判断是否选中此数据项中的复选框
public bool Checked{get;set}
实现代码:
private void Form1_Load(object sender, EventArgs e) { listView1.CheckBoxes = true; listView1.GridLines = true; listView1.View = View.Details; listView1.Columns.Add("文件名称",180,HorizontalAlignment.Left); listView1.Columns.Add("修改日期",217,HorizontalAlignment.Left); foreach (string fileName in Directory.GetFiles("C:\\windows\\")) { FileInfo file = new FileInfo(fileName); ListViewItem OptionItem = new ListViewItem(file.Name); OptionItem.SubItems.Add(file.LastWriteTime.ToString()); listView1.Items.Add(OptionItem); } } private void button1_Click(object sender, EventArgs e) { foreach (ListViewItem lvi in listView1.Items) { if(lvi.Checked==false) lvi.Checked = true; else lvi.Checked = false; } } private void button2_Click(object sender, EventArgs e) { listView1.Items.Clear(); }
标签:window form bubuko obj oid image item tostring clear
原文地址:https://www.cnblogs.com/feiyucha/p/10163799.html