![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
|
|
#1
|
|||
|
|||
|
Привет.
Можно ли загрузить все находящиеся файлы в ListBox-е в ListView? Примерно так как из ListBox1 в ListBox2: Код:
var
Aric : array of String;
i: integer;
begin
SetLength(Aric, ListBox1.Items.Count);
for I := 0 to ListBox1.Items.Count - 1 do
Aric[i]:= ListBox1.Items.Strings[i];
for i:= 0 to ListBox1.Items.Count -1 do
listbox2.Items.Add(Aric[i]);
end; |
|
#2
|
||||
|
||||
|
Цитата:
Добавлено позже Можно, точно так же как в этом коде, только в цикле вместо бокса нужно использовать ListView.Items.Add() Последний раз редактировалось Alegun, 07.10.2013 в 00:56. |
|
#3
|
|||
|
|||
|
Цитата:
Пробовал вот примерно так, но понимаю что не грамотно. Код:
ListView1.SmallImages:= ImageList1;
ListBox1.Selected[0]:= true;
if Listbox1.count = 1 then exit
else
LV_InsertFiles(Pchar(listbox1.Items.Strings[Listbox1.Itemindex]), ListView1, Imagelist1);
ListBox1.itemindex:=Listbox1.itemindex+1;
... |
|
#4
|
||||
|
||||
|
Какие две колонки, может донор не Listbox?Пжлст,образец покажите
Добавлено позже Есть такой код, и он работает Код:
var
i, b:integer;
begin
if OpenDialog1.Execute then
begin
ListView1.SmallImages:= ImageList1;
for i := 0 to Opendialog1.Files.Count - 1 do
LV_InsertFiles(OpenDialog1.Files.Strings[i], ListView1, Imagelist1);
for b := 0 to OpenDialog1.Files.Count - 1 do
ListBox1.Items.Add(OpenDialog1.Files.Strings[b]);
end;
end;Последний раз редактировалось Alegun, 07.10.2013 в 01:34. |
|
#5
|
|||
|
|||
|
Код:
user
shellapi
...
procedure LV_InsertFiles(strPath: string; LV: TListView; IL: TImageList);
var
Icon: TIcon;
ListItem: TListItem;
FileInfo: SHFILEINFO;
begin
// Создать временную TIcon
Icon := TIcon.Create;
LV.Items.BeginUpdate;
ListItem := LV.Items.Add;
// Получить DisplayName
SHGetFileInfo(PChar(strPath), 0, FileInfo,
SizeOf(FileInfo), SHGFI_DISPLAYNAME);
Listitem.Caption := FileInfo.szDisplayName;
// Получить TypeName
SHGetFileInfo(PChar(strPath), 0, FileInfo,
SizeOf(FileInfo), SHGFI_TYPENAME);
ListItem.SubItems.Add(strPath); // Полный путь
// Получить значок, который представляет файл
SHGetFileInfo(PChar(strPath ), 0, FileInfo,
SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON); // Иконка файла
icon.Handle := FileInfo.hIcon;
ListItem.ImageIndex := IL.AddIcon(Icon);
// Destroy the Icon
//DestroyIcon(FileInfo.hIcon);
//Icon.Free;
LV.Items.EndUpdate;
end;
...
begin
ListView1.SmallImages:= ImageList1;
LV_InsertFiles(Pchar(listbox1.Items.Strings[Listbox1.Itemindex]), ListView1, Imagelist1);
end;
...
viewstyle:= vsReport; |
|
#6
|
||||
|
||||
|
У меня точно такой же код как и вас, в этой сборке грузятся имена и пути к файлам в ListView, а в Listbox лишь пути, двух колонок нету
|