I have code that creates controls dynamically and the focus goes to the last control I create. So I am doing a SetFocus, but the focus is not changing.
Whats the trick to it?
procedure Handle_Adventure;
begin
THtml.Add_Hidden_Class (idLocation);
THtml.Add_Hidden_Class (idDestination);
THtml.Remove_Hidden_Class (idCategory);
Create_Pax_Controls;
edtVoucher_Ref.SetFocus;
end;
Creation Code
constructor TPax.Create (AOwner : TWebForm;
ATotal : TFloatField);
function Create_Edit (ANum, AField : string) : TWebEdit;
var
C : TWebEdit;
begin
C := TWebEdit.Create (FOwner);
C.Parent := FOwner;
C.ElementId := 'form.edt'+AField+ANum;
Result := C;
end;
function Create_Combo (ANum, AField : string) : TWebComboBox;
begin
Result := TWebComboBox.Create (FOwner);
Result.Parent := FOwner;
Result.ElementId := 'form.edt'+AField+ANum;
Result.Items.Assign (TVirtual.Weights);
Result.OnChange := Change;
end;
var
I : Integer;
S : string;
begin
inherited Create;
FOwner := AOwner;
FTotal := ATotal;
for I in TRows
do begin
S := IntToStr (I);
FRows [I]._edtFName := Create_Edit (S, 'FName');
FRows [I]._edtLName := Create_Edit (S, 'LName');
FRows [I]._edtWeight := Create_Combo (S, 'Weight');
FRows [I]._edtMobile := Create_Edit (S, 'Mobile');
FRows [I]._edtEmail := Create_Edit (S, 'Email');
end;
end;