基本上我想有一個StringList的填充的ListView控件,當我選擇列表項,並按向上或向下移動時的項目向上或向下(在這兩個列表)。的ListView不選擇正確的行
我使用ListView的的onkeydown調用MoverFAT
procedure TF_Aplicador.ListViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ListView.Selected <> nil then
if Key = VK_UP then
MoverFAT(ListView.Selected.Index, -1)
else if Key = VK_DOWN then
MoverFAT(ListView.Selected.Index, 1)
else if Key = VK_DELETE then
DeletarFAT(ListView.Selected.Index);
end;
而且問題是向下移動時,它總是選擇第一項(交換損益後),並連升作品就好了。 FAT是我的StringList,Atualizar()只是讓ListView顯示StringList的內容。
ListView.Clear;
for I := 0 to FATs.Count - 1 do
ListView.AddItem(FATs[I], nil);
(它肯定會一直是容易得多,如果你給了我們,太)
的問題是:
procedure TF_Aplicador.MoverFAT(I, J: Integer);
begin
if ((I + J) > -1) and ((I + J) < (FATs.Count)) then
begin
FATs.Exchange(I, I+J);
Atualizar;
ListView.Selected := ListView.Items[I+J];
end;
end;
我無法重現那樣的問題。我正在使用過程TForm6.ListViewData(發件人:TObject;項目:TListItem); 開始 Item.Caption:= FATs [Item.Index]; 結束;與OwnerData =真 – bummi 2013-04-22 18:19:22