Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Recorrer Listbox (https://www.clubdelphi.com/foros/showthread.php?t=35265)

DM2005 05-09-2006 21:40:31

Recorrer Listbox
 
Hola a todos, encontre en un hilo a siguiente procedure:

Código Delphi [-]
{$WRITEABLECONST ON}
procedure TForm1.SpeedButton2Click(Sender: TObject);
const
  i: integer = 0;
begin
     with ListBox4 do
        begin
         if i < Count then
          if Items[i] = 'N' then
           begin
             Self.Height := 300;
             Self.Width := 550;
             Self.Left := 400;
             Self.Top := 400;
           end;
          if Items[i] = 'S' then
           begin
             Self.Height := 739;
             Self.Width := 1024;
             Self.Left := 0;
             Self.Top := 0;
           end;
         if i < Count-1 then
            inc(i)
         else
            i:= 0;
        end;
    end;
end;
{$WRITEABLECONST OFF}

esta recorre un listbox, y cuando se encuentra con los item 'N' y 'S', cambia el tamaño del form, la duda es como alterarla para que cuando selecciono un item del listbox (ej.: nº item 22), no recorra el listbox desde el comienzo y si a partir del item que selecciono.
gracias por la ayuda.
Saludos

Northern 05-09-2006 22:12:45

Hola

Miraste la propiedad ItemIndex ? :confused: Empieza el bucle desde ahi :)


Saludos

DM2005 05-09-2006 22:32:04

paso a descriir mi procedure,

Código Delphi [-]
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
  Panel6.Visible := False;
  Panel7.Visible := True;
  if ListBox1.ItemIndex = 0 then
    begin
       ListBox2.Clear;
       ListBox2.Items.LoadFromFile('C:\IPCapitulo.txt');
       ListBox3.Items.LoadFromFile('C:\IPArquivo.txt');
       ListBox4.Items.LoadFromFile('C:\IPMaximizada.txt');
 end;
  if ListBox1.ItemIndex = 1 then
    begin
       ListBox2.Clear;
       ListBox2.Items.LoadFromFile('C:\IPCapitulo.txt');
       ListBox3.Items.LoadFromFile('C:\IPArquivo.txt');
       ListBox4.Items.LoadFromFile('C:\IPMaximizada.txt');
 end;
.
.
.
.
.
end;



Código Delphi [-]
{$WRITEABLECONST ON}
procedure TForm1.SpeedButton2Click(Sender: TObject);
const
  i: integer = 0;
begin
   with ListBox3.Items do
    begin
      if ListBox3.ItemIndex < Count-1
         then ListBox2.ItemIndex := ListBox2.ItemIndex + 1
         else MessageDlg('Você já está no final do curso !',mtInformation,[mbOk],0);
         Panel2.Caption := ListBox2.Items.Strings[ListBox2.ItemIndex];
         WebBrowser1.Navigate(strings[ListBox2.ItemIndex]);
    end;
    begin
     with ListBox4 do
        begin
         if i < Count then
          if Items[i] = 'N' then
           begin
             Self.Height := 300;
             Self.Width := 550;
             Self.Left := 400;
             Self.Top := 400;
           end;
          if Items[i] = 'S' then
           begin
             Self.Height := 739;
             Self.Width := 1024;
             Self.Left := 0;
             Self.Top := 0;
           end;
         if i < Count-1 then
            inc(i)
         else
            i:= ListBox4.ItemIndex;
        end;
    end;
end;
{$WRITEABLECONST OFF}

espero ayude a entender,
gracias
saludos


La franja horaria es GMT +2. Ahora son las 00:51:58.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi