Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Ayuda Boton Siguiente... (https://www.clubdelphi.com/foros/showthread.php?t=70253)

tecnoman 09-10-2010 18:11:43

Ayuda Boton Siguiente...
 
Hola, Acabo De Registrarme En El Foro Y Es Que Tengo Una Inquietud, Estoy Desarrollando Una Aplicacion En Delphi Para Impartir Examenes, Tengo Un Form Y He Colocado Conjuntos De Preguntas En Panels Y Tengo El Siguiente Inconveniente, Coloque Un Boton Siguiente Y Otro Anterior Para Cambiar Al Siguiente Bloque De Preguntas, Osea Al Panel 2, Pero No He Podido Pasarlo A Un Tercer Panel Y Asi Sucesivamente, Ya Que Al Precionar El Boton Siguiente Se Va Del Primero Al Ultimo Y Necesito Que Sea De Forma Secuencial.

Alguien Puede Decirme Como Puedo Hacerlo Con Panela U Otro Componente... Gracias

felipe88 09-10-2010 18:25:10

Yo cambiaría los paneles por un PageControl, así podría añadir cuantos TabSheet necesite para las preguntas.

Luego en los botones Anterior y Siguiente solo tendría que usar esto:

Código Delphi [-]
procedure TForm1.botonanteriorClick(Sender: TObject);
begin
  PageControl1.Pages[PageControl1.TabIndex - 1].Show;
end;

procedure TForm1.botonsiguienteClick(Sender: TObject);
begin
  PageControl1.Pages[PageControl1.TabIndex + 1].Show;
end;


Saludos!

felipe88 09-10-2010 18:29:52

Añado... hay que colocar un manejo de excepción cuándo estes en el primer Tab e intentes ir hacia atras o en el último e intentes ir hacia adelante.

Saludos!

ecfisa 09-10-2010 21:32:48

Hola.

Los desbordes de índice también se pueden evitar de este modo:
Código Delphi [-]
procedure TForm1.btSiguienteClick(Sender: TObject);
begin
  with PageControl1 do
  begin
    if ActivePage.PageIndex < PageCount-1 then
      Pages[PageControl1.TabIndex + 1].Show
    else
      Pages[0].Show;
  end;
end;

procedure TForm1.btAnteriorClick(Sender: TObject);
begin
  with PageControl1 do
  begin
    if ActivePage.PageIndex > 0 then
      PageControl1.Pages[PageControl1.TabIndex - 1].Show
    else
      Pages[PageCount-1].Show;
  end;
end;

Saludos. :)

tecnoman 09-10-2010 21:52:21

GRACIAS AMIGOS

PARA EVITAR LOS DESBORDES LO HICE ASI:

procedure TForm1.BSIGUIENTEClick(Sender: TObject);
begin
PageControl1.Pages[PageControl1.TabIndex + 1].Show;

if pagecontrol1.TabIndex >= 1 then
button2.Enabled:=true;

if pagecontrol1.TabIndex >= 2 then
button1.Enabled:=false
else
button1.Enabled:=true;
end;

procedure TForm1.BANTERIORClick(Sender: TObject);
begin
PageControl1.Pages[PageControl1.TabIndex - 1].Show;

if pagecontrol1.TabIndex >= 1 then
button2.Enabled:=true;

if pagecontrol1.TabIndex = 0 then
button2.Enabled:=false
else
button1.Enabled:=true;
end;

LO PROBE CON 3 TABSHEET, DE ESA FORMA PUEDO CONTROLAR QUE CUANDO LLEGUE AL PRIMER O ULTIMO TAP LOS BOTONES SE INACTIVEN, NO SE SI ES LA MEJOR FORMA PERO FUNCIONA

GRACIAS POR SU AYUDA, SON UNOS GENIOS...

cmm07 09-10-2010 23:44:10

ok una cosilla más, si quieres q se vea como un panel sencillo y ordinario :D, entonces revisa el componente TNotebook, puedes cambiar de hoja o página con esto:

Código Delphi [-]
Notebook1.PageIndex := Notebook1.PageIndex + 1

saludos!


otra cosilla, para poner código de delphi aqui te recomiendo q uses el comando "[ Delphi]" <- el q inicia la instrucción, ny "[ /Delphi] <- el q cierra.

ej :
"[ DELPHI]
MI CODIGO
[/delphi]"

saludos , sin las comillas ni los espacios eh?!

felipe88 10-10-2010 03:40:16

Optimizado, con excepciones y habilitando o deshabilitando el boton ;)

Código Delphi [-]
procedure TForm1.btatrasClick(Sender: TObject);
begin
  PageControl1.TabIndex := PageControl1.TabIndex - 1;
  btatras.Enabled := (PageControl1.TabIndex <> 0);
  btsiguiente.Enabled := True;
end;

procedure TForm1.btsiguienteClick(Sender: TObject);
begin
  PageControl1.TabIndex := PageControl1.TabIndex + 1;
  btsiguiente.Enabled := (PageControl1.TabIndex <> (PageControl1.PageCount - 1));
  btatras.Enabled := True;
end;


Saludos!


La franja horaria es GMT +2. Ahora son las 08:12:22.

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