listbox删除
删除选中的某个:procedure TForm1.Button1Click(Sender: TObject); var i:integer;begin i:=0; while i 0) then
begin
Items.Move(ItemIndex, ItemIndex - 1);
lst2.SetFocus;
lst2.Selected[ActiveItem - 1] := True;
end;
end;
end;
向下移动
procedure TFormMain.RzBmpButton6Click(Sender: TObject);
var
ActiveItem: Integer;
begin
with lst2 do
begin
ActiveItem := ItemIndex;
if (ItemIndex >= 0) and (ItemIndex < Items.Count - 1) then
begin
Items.Move(ItemIndex, ItemIndex + 1);
lst2.SetFocus;
lst2.Selected[ActiveItem + 1] := True;
end;
end;
end;
拖拽事件
procedure TFormMain.lst2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
StartingPoint.X := X;
StartingPoint.Y := Y;
end;
procedure TFormMain.lst2DragDrop(Sender, Source: TObject; X, Y: Integer);
var
DropPosition, StartPosition: Integer;
DropPoint: TPoint;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TRzListBox do
begin
StartPosition := ItemAtPos(StartingPoint, True);
DropPosition := ItemAtPos(DropPoint, True);
Items.Move(StartPosition, DropPosition);
end;
end;
procedure TFormMain.lst2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = lst2;
end;
时间的步伐有三种:未来姗姗来迟,现在像箭一样飞逝,过去永远静立不动.务请珍惜