Cita:
Empezado por mRoman
LISTO YA ESTA .... esta es la solucion.
[delphi]
procedure TfrmRuta.btnArribaClick(Sender: TObject);
var
Indice:integer;
begin
inherited;
if lBoxLecherias.ItemIndex>0 then
begin
indice:=lBoxLecherias.ItemIndex;
lBoxLecherias.Items.Exchange(Indice,indice-1);
end
else.....
|
Ya mejore el codigo del post anterior....
declare una variable privada para usarla en cualquier parte del codigo, llamada FlagUpDw de tipo integer.
Código Delphi
[-] private
j,i:integer;
FlagUpDw : integer; public
end;
Y luego modifique un poco el codigo como sigue
Código Delphi
[-]procedure TfrmRuta.btnArribaClick(Sender: TObject);
var
Indice:integer;
begin
inherited;
if lBoxLecherias.ItemIndex>0 then
begin
indice:=lBoxLecherias.ItemIndex;
lBoxLecherias.Items.Exchange(Indice,indice-1);
if FlagUpDw=1 then
lBoxLecherias.Selected[indice]:=true; end
else
lBoxLecherias.ItemIndex:=0;
end;
procedure TfrmRuta.btnAbajoClick(Sender: TObject);
var
Indice:Integer;
begin
inherited;
if lBoxLecherias.ItemIndex< lBoxLecherias.Items.Count-1 then
begin
indice:=lBoxLecherias.ItemIndex;
lBoxLecherias.Items.Exchange(Indice,indice+1);
if FlagUpDw=1 then
lBoxLecherias.Selected[indice]:=true;
end
else
lBoxLecherias.ItemIndex:=lBoxLecherias.Items.Count-1;
end;
procedure TfrmRuta.lBoxLecheriasKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if (ssShift in Shift) and (Key=VK_UP) then
begin
btnArribaClick(Sender);
end;
if (ssShift in Shift) and (Key=VK_DOWN) then
begin
btnAbajoClick(Sender);
end;
FlagUpDw:=1;
end;
procedure TfrmRuta.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case Key of
VK_F2 : Begin
if not(dsRutaDistribucion.IsEmpty) then
begin
if FindComponent('frmBuscarLech') = nil then
frmBuscarLech:=TfrmBuscarLech.Create(self);
frmBuscarLech.Show;
end;
end;
end;
end;
procedure TfrmRuta.GroupBox1Enter(Sender: TObject);
begin
inherited;
FlagUpDw:=0;
end;
Y de esta manera puede solucionar que la parte sobreada siguiera sombreada para quede como referencia para el usuario y el vea que registro esta moviendo....tanto con los botones como con las combinaciones de teclas shift+flecha.
Se los dejo para futuras consultas de otros delphineros....
Creo q este hilo ha cumplido el objetivo, que era mover lineas dentro un ListBox hacia arriba y hacia abajo usando tanto conbinaciones de teclas (shift+flechas) como con botones.
Gracias por sus comentarios, aportaciones y orientaciones. GRACIAS.