Foros Club Delphi

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

Jere_84 05-06-2012 15:50:16

Recorrer Page Control
 
Hola, estoy haciendo un procedure que valida campos vacíos recorriendo los componentes del Form y haciendo foco en el TDBEdit cuando esta vació. El problema surge si el componente se encuentra dentro de un TPageControl y hay que hacer el Set focus cuando Tab del PageControl no esta en foco.

Alguien sabe como podría obtener los componentes hijos y que frene cuando lo encuentre o algo así?

Slds.

Código Delphi [-]
for a:=0 to TJfPageControl(vForm.Components[i]).Tabs[a].Index do
begin
 // detener en la pagina donde esta el TDbedit
end;

Caro 05-06-2012 16:51:25

Hola Jere_84, al recorrer cada TabSheet puedes obtener el TabIndex donde haya un Edit vacio.

Código Delphi [-]
//con el pagecontrol normal sería algo así
 sheet : TTabSheet;
begin
 for i:=0 to PageControl1.ControlCount-1 do
 begin
  sheet := TTabSheet(PageControl1.Controls[i]);
  for a:=0 to sheet.ControlCount-1 do
   begin
    if sheet.Controls[a] is TEdit then
     if TEdit(sheet.Controls[a]).Text = '' then
      begin
       PageControl1.TabIndex := sheet.TabIndex;
       TEdit(sheet.Controls[a]).SetFocus;
       exit;
      end;
   end;
 end;

Saluditos

Jere_84 05-06-2012 16:56:48

Cita:

Empezado por Caro (Mensaje 434343)
Hola Jere_84, al recorrer cada TabSheet puedes obtener el TabIndex donde haya un Edit vacio.

Código Delphi [-]
//con el pagecontrol normal sería algo así
 sheet : TTabSheet;
begin
 for i:=0 to PageControl1.ControlCount-1 do
 begin
  sheet := TTabSheet(PageControl1.Controls[i]);
  for a:=0 to sheet.ControlCount-1 do
   begin
    if sheet.Controls[a] is TEdit then
     if TEdit(sheet.Controls[a]).Text = '' then
      begin
       PageControl1.TabIndex := sheet.TabIndex;
       TEdit(sheet.Controls[a]).SetFocus;
       exit;
      end;
   end;
 end;

Saluditos

Gracias caro, lo voy a probar!

Saludos!


La franja horaria es GMT +2. Ahora son las 23:41:13.

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