|
#1
|
||||
|
||||
FileListBox
Здравствуйте. Требуется ваша помощь. Уже второй день не могу сообразить.
Имеется код для перемещения строк по FileListBox вверх/вниз. Как сделать чтобы при перемещении строки , перемещаемая строка оставалась выделенной? Код работает как положено, но как-то нелогично получается когда выделил строку нажал кнопку "вверх" и выделение пропало. Хочется добиться аккуратного эффекта. Код:
{выделяем и перемещаем вверх} procedure TForm9.act_UpExecute(Sender: TObject); begin if FileListBox1.ItemIndex < 0 then exit; if FileListBox1.ItemIndex = 0 then begin FileListBox1.Items.Move(0, Pred(FileListBox1.Items.Count)); FileListBox1.ItemIndex := Pred(FileListBox1.Items.Count) end else FileListBox1.Items.Exchange(FileListBox1.ItemIndex, Pred(FileListBox1.ItemIndex)); end; {выделяем и перемещаем вниз} procedure TForm9.act_DownExecute(Sender: TObject); begin if FileListBox1.ItemIndex < 0 then exit; if FileListBox1.ItemIndex = Pred(FileListBox1.Items.Count) then begin FileListBox1.Items.Move(Pred(FileListBox1.Items.Count), 0); FileListBox1.ItemIndex := 0 end else FileListBox1.Items.Exchange(FileListBox1.ItemIndex, Succ(FileListBox1.ItemIndex)); end; Последний раз редактировалось Cave, 17.11.2021 в 16:02. |