Ver Mensaje Individual
  #2  
Antiguo 07-09-2007
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 26
maeyanes Va por buen camino
Hola...

Tienes dos opciones:

Código Delphi [-]
var
  I, J: Integer;

begin
  for I := 0 to Pred(DataSet.Fields.Count) do
    for J := 0 to Pred(Form.ComponentCount) do
      if (Form.Components[J] is TEdit) and (DataSet.Fields[i].FieldName = Form.Components[J].Name) then
      begin
        TEdit(Form.Components[J]).Text := DataSet.Fields[i].AsString;
        Break // Dejamos de buscar en los controles
      end
end;

La otra opción es usar el método FindComponent:

Código Delphi [-]
var
  I: Integer;
  Edit: TEdit;

begin
  for I := 0 to Pred(DataSet.Fields.Count) do
  begin
    Edit := Form.FindComponent(DataSet.Fields[i].FieldName) as TEdit;
    if Assigned(Edit) then
      Edit.Text := DataSet.Fields[i].AsString
  end
end;

Saludos...
Responder Con Cita