使用ListView如何达到Windows资源管理器中显示文件夹和文件一样的功能?不同类型的文件的图标不一样,使用本机关联的文件类型图标!
文件夹容易找到图标,但是我不可能为每一种文件都准备一个图标吧!!应该怎么实现?

解决方案 »

  1.   

    http://www.codeproject.com/有例子,下一个看看啊.
      

  2.   

    这是个TreeView的,但是方法都是一样的,你看看吧:http://www.codeproject.com/cs/miscctrl/treeviewexplorer.asp
      

  3.   

    我在学校里面,上不了http://www.codeproject.com/
    郁闷!!大哥请帖一下代码吧!!谢谢!!
      

  4.   

    using System.Runtime.InteropServices;......[StructLayout(LayoutKind.Sequential)]
    public struct SHFILEINFO
    {
                               public IntPtr hIcon;
    public int iIcon;
    public int dwAttr;
    public string szDisplayName;
    public string szTypeName;
    }[System.Runtime.InteropServices.DllImport("shell32")]
    private static extern int SHGetFileInfo(string pszPath, int dwFileAttr, ref SHFILEINFO psfi, int cbFileInfo, int uFlags);
    //copy from shellapi.h
    const int SHGFI_ICON              = 0x000000100;     // get icon
    const int SHGFI_DISPLAYNAME       = 0x000000200;     // get display name
    const int SHGFI_TYPENAME          = 0x000000400;     // get type name
    const int SHGFI_ATTRIBUTES        = 0x000000800;     // get attributes
    const int SHGFI_ICONLOCATION      = 0x000001000;     // get icon location
    const int SHGFI_EXETYPE           = 0x000002000;     // return exe type
    const int SHGFI_SYSICONINDEX      = 0x000004000;     // get system icon index
    const int SHGFI_LINKOVERLAY       = 0x000008000;     // put a link overlay on icon
    const int SHGFI_SELECTED          = 0x000010000;     // show icon in selected state
    const int SHGFI_ATTR_SPECIFIED    = 0x000020000;     // get only specified attributes
    const int SHGFI_LARGEICON         = 0x000000000;     // get large icon
    const int SHGFI_SMALLICON         = 0x000000001;     // get small icon
    const int SHGFI_OPENICON          = 0x000000002;     // get open icon
    const int SHGFI_SHELLICONSIZE     = 0x000000004;     // get shell size icon
    const int SHGFI_PIDL              = 0x000000008;     // pszPath is a pidl
    const int SHGFI_USEFILEATTRIBUTES = 0x000000010;     // use passed dwFileAttribute[System.Runtime.InteropServices.DllImport("user32")]
    private static extern bool DestroyIcon(IntPtr hIcon);
    ......SHFILEINFO fileInfo = new SHFILEINFO();SHGetFileInfo(strFileName, 
        0, 
        ref fileInfo, 
        Marshal.SizeOf(fileInfo), 
        SHGFI_ICON | SHGFI_SMALLICON);Icon icon = Icon.FromHandle(fileInfo.hIcon);DestroyIcon(fileInfo.hIcon);......
      
      

  5.   

    http://blog.csdn.net/jiangsheng/archive/2003/11/20/3796.aspx
      

  6.   

    我想知道以下这一段有什么用,还有怎么用???//copy from shellapi.h
    const int SHGFI_ICON              = 0x000000100;     // get icon
    const int SHGFI_DISPLAYNAME       = 0x000000200;     // get display name
    const int SHGFI_TYPENAME          = 0x000000400;     // get type name
    const int SHGFI_ATTRIBUTES        = 0x000000800;     // get attributes
    const int SHGFI_ICONLOCATION      = 0x000001000;     // get icon location
    const int SHGFI_EXETYPE           = 0x000002000;     // return exe type
    const int SHGFI_SYSICONINDEX      = 0x000004000;     // get system icon index
    const int SHGFI_LINKOVERLAY       = 0x000008000;     // put a link overlay on icon
    const int SHGFI_SELECTED          = 0x000010000;     // show icon in selected state
    const int SHGFI_ATTR_SPECIFIED    = 0x000020000;     // get only specified attributes
    const int SHGFI_LARGEICON         = 0x000000000;     // get large icon
    const int SHGFI_SMALLICON         = 0x000000001;     // get small icon
    const int SHGFI_OPENICON          = 0x000000002;     // get open icon
    const int SHGFI_SHELLICONSIZE     = 0x000000004;     // get shell size icon
    const int SHGFI_PIDL              = 0x000000008;     // pszPath is a pidl
    const int SHGFI_USEFILEATTRIBUTES = 0x000000010;     // use passed dwFileAttribute
      

  7.   

    http://www.cnblogs.com/wdxinren/archive/2005/01/03/85655.html这里有详细的翻译