列出带有复选框的文件(C#/WinForms) [英] Listing Files With CheckBoxes (C# / WinForms)

查看:109
本文介绍了列出带有复选框的文件(C#/WinForms)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一种列出目录中文件的方法,并在每个文件旁边放置一个复选框,以便我可以选择其中一些并对每个选定的文件执行操作,这是最好的方法?

I want a way to list files in a directory and putting a check box beside each one of them so I can select some of them and perform operations with each selected file, what's the best way to do this?

推荐答案

将CheckedListBox控件拖放到窗体上,然后使用DirectoryInfo和FileSystemInfo类填充内容,如下所示:

Drop a CheckedListBox control onto the form, then populate the contents using the DirectoryInfo and FileSystemInfo classes, like this:

System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("c:\\");
System.IO.FileSystemInfo[] files = di.GetFileSystemInfos();
checkedListBox1.Items.AddRange(files);

这篇关于列出带有复选框的文件(C#/WinForms)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆