Ver Mensaje Individual
  #7  
Antiguo 16-04-2009
Avatar de mRoman
mRoman mRoman is offline
Miembro
 
Registrado: nov 2003
Posts: 646
Reputación: 23
mRoman Va por buen camino
Cita:
Empezado por mRoman Ver Mensaje
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
    { Private declarations }
    j,i:integer;
    FlagUpDw : integer;  public
    { Public declarations }
  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;
   { Codigo que combina las teclas SHIFT y TECLAS DE FLECHA, para mover lineas hacia
    arriba o hacia abajo dentro del ListBox}
  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.
__________________
Miguel Román

Afectuoso saludo desde tierras mexicanas....un aguachile?, con unas "cetaseas" bien "muertas"?, VENTE PUES !!

Última edición por mRoman fecha: 16-04-2009 a las 03:30:30.
Responder Con Cita