L
lcl_003
Unregistered / Unconfirmed
GUEST, unregistred user!
我想控制listview的记录,让它上下移动。我写了个将记录向上移动的代码,可是只实现
了一部分,只有第一列的记录移动了,其他列没有重新付值。啊-----说起来太麻烦,看
看代码其实很简单
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
j:Tstrings;
begin
s:=listview1.Items[listview1.ItemIndex-1].caption;
listview1.Items[listview1.ItemIndex-1].Caption:=listview1.Items[listview1.ItemIndex].Caption;
listview1.Items[listview1.ItemIndex].Caption:=s;
j:=listview1.Items[listview1.ItemIndex-1].SubItems;
listview1.Items[listview1.ItemIndex-1].SubItems:=listview1.Items[listview1.ItemIndex].SubItems;
listview1.Items[listview1.ItemIndex].SubItems:=j;
listview1.Selected:=listview1.Items[listview1.itemindex-1];
end;
哦,还有最后一行代码。我想控制listview的那行被选择,怎么不行?
了一部分,只有第一列的记录移动了,其他列没有重新付值。啊-----说起来太麻烦,看
看代码其实很简单
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
j:Tstrings;
begin
s:=listview1.Items[listview1.ItemIndex-1].caption;
listview1.Items[listview1.ItemIndex-1].Caption:=listview1.Items[listview1.ItemIndex].Caption;
listview1.Items[listview1.ItemIndex].Caption:=s;
j:=listview1.Items[listview1.ItemIndex-1].SubItems;
listview1.Items[listview1.ItemIndex-1].SubItems:=listview1.Items[listview1.ItemIndex].SubItems;
listview1.Items[listview1.ItemIndex].SubItems:=j;
listview1.Selected:=listview1.Items[listview1.itemindex-1];
end;
哦,还有最后一行代码。我想控制listview的那行被选择,怎么不行?