FormControlList Property


Applies to

THtmlViewer component

Declaration

property FormControlList: TList;

Read only and run time only. The FormControlList contains a list of all the Form controls contained in the currently displayed document. This list enables the programmer to access the controls to read or initialize them while displayed on screen. Some hints on using this list:

Declare htmlsubs.pas and htmlsbs1 in your uses clause.

Study the definition of TFormControlObj and its decendents (in htmlsubs.pas) as you will probably need to access the fields and methods to make use of the FormControlList.

Give any control you want to access a distinctive Name (the Name= item) when defining it in the HTML document. This name can be used to identify the control when searching through the list.

The FormControlList is used by THtmlViewer. Do not Free this list.

Examples:

In the code below, clicking Button4 causes the first form in the document to be submitted. (Viewer is the THtmlViewer displaying the document.)

procedure TForm1.Button4Click(Sender: TObject);

begin

if Viewer.FormControlList.Count > 0 then

TFormControlObj(Viewer.FormControlList.Items[0]).MyForm.SubmitTheForm('');

end;

In the following, clicking Button5 initializes the TEdit control with the name, "Address"

procedure TForm1.Button5Click(Sender: TObject);

var

I: integer;

begin

with Viewer.FormControlList do

for I := 0 to Count -1 do

if CompareText(TFormControlObj(Items[I]).Name, 'Address') = 0 then

begin

if TFormControlObj(Items[I]).TheControl is TEdit then

TEdit(TFormControlObj(Items[I]).TheControl).Text := '144 Sands Point';

Exit;

end;

end;

See Also:

FormData Property

OnFormSubmit Event

IDControl Property