namespace explorer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DirectoryInfo di = new DirectoryInfo("c:\\test");
FileSystemInfo[] files = di.GetFileSystemInfos();
checkedListBox1.Items.AddRange(files);
}
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
for (int ix = 0; ix < checkedListBox1.Items.Count; ++ix)
if (ix != e.Index) checkedListBox1.SetItemChecked(ix, false);
}
//removed irrelevant parts of the code
}
}
我忘记了如何为选中列表框构建事件处理程序。我需要选择一个。我有多个文件,但我只需要通过复选框选择一个。