我想在列表视图中显示文件名,但问题是列表视图没有显示任何项目。奇怪的部分是 listview.items.count 表明项目已正确添加。项目只是不显示在任何类型的 listview.view 中。编辑:ListView 被拖放到选项卡控件上。
string[] files;
bool error = false;
try
{
files = Directory.GetFiles(addDir /* this is the folder path*/, "*.txt", SearchOption.AllDirectories);
}
catch(Exception ex)
{
// the code will jump here if there any access restrictions
MessageBox.Show(ex.Message);
error = true;
}
if(!error)
{
foreach (string fi in files)
{
string fnameonly = System.IO.Path.GetFileNameWithoutExtension(fi);
_listView1.Items.Add(fnameonly);
}
}
茅侃侃
繁华开满天机
相关分类