tavria2

Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору BLACK ROZE Цитата: при загрузке треков из следующего альбома (нажатием кнопки) они просто добавляются в ListBox, а мне нужно чтобы он обновлялся (удаление предыдущих трэков и показ новых). | Перед заполнением ListBox, очищай его с помощью ListBox.DeleteItem. Цитата: Такой код на каждой кнопке, только папки с трэками разные | такой код будет избыточным, нужно создать одну глобальную функцию и вызывать ее из разных кнопок, передавая ей в параметрах путь к трэкам. Событие Global Functions: Код: function FillListBox(sPath) -- Find all the files in the directory tFiles = File.Find(sPath, "*.*", false, false, nil); -- If tFiles contains something if tFiles then -- Remove all items from the listbox ListBox.DeleteItem("ListBox1", LB_ALLITEMS); -- Traverse the table containing the selected file paths for nIndex, sFilePath in tFiles do -- Assign the desired text and data to variables sData = sFilePath; -- Set sText to the filename (without extension) using String.SplitPath sText = String.SplitPath(sFilePath).Filename; -- Add the item to the ListBox ListBox.AddItem("ListBox1", sText, sData); end end end | Событие кнопки On Click: Код: -- Вызов функции FillListBox("AutoPlay\\Audio\\HP&SK"); |
| Всего записей: 1127 | Зарегистр. 19-01-2005 | Отправлено: 20:10 12-05-2010 | Исправлено: tavria2, 20:13 12-05-2010 |
|