Delphi问题:ListView里面如何实现记录的上下移动?,并改变当前记录的颜色?

2025-05-09 02:06:34
推荐回答(2个)
回答(1):

if (SelectedIndex - 1) < 0 then Exit;
ListBox1.Items.Move(SelectedIndex, (SelectedIndex - 1));
ListBox1.ItemIndex := SelectedIndex - 1;
ListBox1.Selected[SelectedIndex - 1] := True;

//还有的自己研究吧,不难
SetFocus
count,i:integer
try
if ListBox1 = nil then
Exit;
Count := ListBox1.Items.Count;
if Count = 0 then
Exit;
for I := 0 to IndexCount - 1 do
ListBox.Selected[i] := False;
ListBox.Selected[0] := true;
except

end;
listbox1.Canvas.Brush.Color :=Clred;//背景
listbox1.Canvas.Font.Color :=Clred;//字体
end;

回答(2):

ADOQuery1.RecNo是只读的,不能加减,它是用来返回当前记录的记录号的。上下移动记录用ADOQuery1.Prior和ADOQuery1.Next。