首页 > 解决方案 > delphi DirectoryListBox 获取选中的目录名

问题描述

我在 delphi 中使用 dirListBox。我无法获取所选目录的子目录名称。它给了我根直接名称。如何获取选定的目录名称?

在此处输入图像描述

标签: directory

解决方案


dirListBox.Directory 返回父目录,而不是子目录。

我可以获得正确名称的唯一方法是使用 itemindex。当您单击或将光标移动到目录时,itemindex 会更新。

 fMain.eProject.Text:=fProject.dirlistBox.Items[fProject.dirListBox.ItemIndex];
 fMain.ePath.Text:=fProject.dirListBox.GetItemPath(fProject.dirListBox.ItemIndex);

推荐阅读