Hola amigos del foro, resulta que cuando presiono la tecla enter se me pierde el focus... el código que tengo es el siguiente
Código Delphi
[-]procedure TfTraslados.Departamento_PChange(Sender: TObject);
begin
if (Departamento_P.GetTextLen > 2)and(Departamento_P.Focused) then
begin
if fDatos.ConsultarSQL(qBusquedas, 'select Codigo, Departamento '
+'descripcion from Departamentos where Departamento like ''%'
+Departamento_P.Text+'%''') then
DBGrid1.Visible:= True
else
DBGrid1.Visible:= False
end
else
begin
DBGrid1.Visible:= False;
qBusquedas.Close;
end;
end;
procedure TfTraslados.Departamento_PKeyPress(Sender: TObject; var Key: Char);
begin
if (Key = Enter) and (Departamento_P.GetTextLen > 1) then
begin
DBGrid1Exit(Sender);
Municipio_P.SetFocus;
end;
end;
procedure TfTraslados.Departamento_PKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_UP: begin
Key := 0;
end;
VK_DOWN: begin
if DBGrid1.Visible then
DBGrid1.SetFocus; Key := 0;
end;
end;
end;
procedure TfTraslados.DBGrid1Exit(Sender: TObject);
begin
if (qBusquedas.IsEmpty) or ( not qBusquedas.Active) then
begin
DBGrid1.Visible:= False;
qBusquedas.Close;
Exit;
end;
case buscando of
0: begin
depcodigo:= qBusquedas.FieldByName('codigo').AsString;
Departamento_P.Text:= qBusquedas.FieldByName('descripcion').AsString;
end;
1: begin
depcodigo:= qBusquedas.FieldByName('codigo').AsString;
Municipio_P.Text:= qBusquedas.FieldByName('descripcion').AsString;
end;
2: begin
depcodigo:= qBusquedas.FieldByName('codigo').AsString;
EPS_P.Text:= qBusquedas.FieldByName('descripcion').AsString;
end;
end;
DBGrid1.Visible:= False;
qBusquedas.Close;
end;
procedure TfTraslados.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if(Key = Enter)then
DBGrid1Exit(Sender);
end;
La cuestión es que cuando presiono enter en el caja de texto, esto me debería llevar la siguiente caja pero no sucede así...
Mi pregunta Cómo hago para saber en donde se encuentra el Focus....
Gracias por vuestro tiempo
Gustavo Cruz