var
Path, PathName: string;
Folder: TShellFolder;
I: Integer;
begin
Path := IncludeTrailingPathDelimiter(List.RootFolder.PathName) + 'New Folder';
if not CreateDir(Path) then Exit;
List.Refresh;
for I := 0 to List.Items.Count-1 do
begin
Folder := List.Folders[I];
if (Folder <> nil) and (Folder.PathName = Path) then
begin
List.Items[I].EditCaption;
Exit;
end;
end;
end;
或者:
var
Path: string;
Item: TListItem;
begin
Path := IncludeTrailingPathDelimiter(List.RootFolder.PathName) + 'New Folder';
if not CreateDir(Path) then Exit;
List.Refresh;
Item := List.FindCaption(0, 'New Folder', False, True, False);
if Item <> nil then
Item.EditCaption;
end;
MkDir(List.RootFolder.PathName+'\New Folder');
List.Update;
List.ItemIndex:=0;
List.HideSelection:=True;
while List.ItemIndex<List.Items.Count-1 do
begin
// Find the New Folder
if List.SelectedFolder.PathName=(List.RootFolder.PathName+ '\New Folder') then
begin
//Set the Folder in Edit mode & exit the loop
List.Items[List.ItemIndex].EditCaption;
Exit;
end
else
//Inc the Index
List.ItemIndex := List.ItemIndex+1;
end;
List.HideSelection:=False;
2条答案
按热度按时间px9o7tmv1#
试试这样的方法:
或者:
h43kikqp2#
我找到了一个解决办法: