ListView as windows explorer
do you know any good example how to create listView which will look and has the same methods as windows explorer.
copying, pasting, display thumbnails ??
I must use listView because I can't allow user to change directory, and I can't disable this option in windows explorer(I mean the place where can I click to go up 开发者_运维问答or down or put path.
I've been recommending this project, never heard a complaint about it. Note that an embeddable browser is available since Vista, it is wrapped by the ExplorerBrowser class available in the Windows API Code Pack.
Beware that these kind of solutions put a lot of dependencies into your project. Consider weighing that cost against simply implementing the OpenFileDialog's FileOk event and canceling the OK button click if you don't like the path.
It's no trivial task, but you can have a look at this project. It's in VB.Net but it might serve as a source of inspiration.
I wrote something, but I don't know how to add event on click on icon to get path of this icon.
path = folderBrowserDialog1.SelectedPath;
ImageList imageList1 = new ImageList();
imageList1.ImageSize = new Size(256, 256);
imageList1.ColorDepth = ColorDepth.Depth24Bit;
string[] iconFiles = Directory.GetFiles(path, "*.jpg");
foreach (string iconFile in iconFiles)
{
try
{
imageList1.Images.Add(Image.FromFile(iconFile));
}
catch
{
MessageBox("Error","");
}
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList1;
for (int j = 0; j < imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
How to rebuild this code ??
You can use Graphics.DrawImage to load the jog file and create a thumbnail out of it. This will only work for image files.
To get thumbnails of other file types, you must use the shell IExtractIcon interface.
For copying/pasting, use the DataFormats.FileDrop format with full paths of the files.
For a ready-made alternative, see our FileView control.
精彩评论