标题:listview总是不能够正确显示
只看楼主
myseemylife
Rank: 2
等 级:论坛游民
帖 子:100
专家分:58
注 册:2009-3-22
结帖率:91.67%
 问题点数:0 回复次数:2 
listview总是不能够正确显示
程序代码:
using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using namespace 遍历文件夹
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Clear();
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = folderBrowserDialog1.SelectedPath;
                DirectoryInfo dinfo = new DirectoryInfo(textBox1.Text);
                FileSystemInfo[] fsinfos = dinfo.GetFileSystemInfos();
                foreach (FileSystemInfo fsinfo in fsinfos)
                {
                    if (fsinfo is DirectoryInfo)
                    {
                        ListViewItem lstItem = new ListViewItem();
                        DirectoryInfo dirinfo = new DirectoryInfo(fsinfo.FullName);
        
                           lstItem.SubItems.Add(dirinfo.Name);
                           lstItem.SubItems.Add(dirinfo.FullName);
                          lstItem.SubItems.Add("");
                          lstItem.SubItems.Add(dirinfo.CreationTime.ToShortDateString()); 
                          listView1.Items.Add( lstItem);
                          listView1.View = View.Details;
                    }
                    else
                    { 
                        ListViewItem lstItem = new ListViewItem();
                        FileInfo finfo = new FileInfo(fsinfo.FullName);

                        lstItem.SubItems.Add(finfo.Name);
                        lstItem.SubItems.Add(finfo.FullName);
                        lstItem.SubItems.Add(finfo.Length.ToString());
                       lstItem.SubItems.Add(finfo.CreationTime.ToShortDateString()); 
                        listView1.Items.Add( lstItem);
                        listView1.View = View.Details;
                     
                   

                     


                    }

                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listView1.Columns.Add("文件名");
            listView1.Columns.Add("路径");
            listView1.Columns.Add("大小");
            listView1.Columns.Add("创建日期");
        }
    }
}

很纠结~~view属性设置成了detail。可是还是不能正确显示
搜索更多相关主题的帖子: listview 
2010-05-30 15:19
xueshui20
Rank: 5Rank: 5
等 级:职业侠客
威 望:1
帖 子:269
专家分:309
注 册:2009-4-19
得分:0 
请问能说清楚点吗?到底是怎样不能正确显示呀?
2010-05-30 22:31
myseemylife
Rank: 2
等 级:论坛游民
帖 子:100
专家分:58
注 册:2009-3-22
得分:0 
回复 2楼 xueshui20
遍历文件夹.rar (36.04 KB)
..我把代码发上来了~~~大家看看·~~

唔紸縡唔自己の鉎銘.................
2010-05-31 12:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-308712-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022932 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved