THtmlViewer component
property FormData: TFreeList;
The FormData Property is used internally by THtmlViewer for storing and restoring HTML Form data in HTML documents. Users may also use this property for the same purpose or to read and/or modify Form data.
As read from THtmlViewer, the FormData consists of a list of TStringLists, one TStringList for each Form in the document. Each string in the TStringList consists of a Name, Value pair separated by an '=' sign:
<name>=<value>
where <name> is the Name attribute assigned to the form control and <value> is the value entered (or the default value if none has been entered).
When an assignment is made to FormData, the same format is used.
Example 1:
The following shows code for saving and later restoring all the Form data in a document:
var
List: TFreeList; {htmlun2 must be in Uses clause}
procedure TForm1.SaveButtonClick(Sender: TObject);
begin
List := Viewer.FormData;
end;
procedure TForm1.RestoreButtonClick(Sender: TObject);
begin
if Assigned(List) then
begin
Viewer.FormData := List;
List.Free;
List := Nil;
end;
end;
Example 2:
In the following, two controls in the first form are modified:
procedure TForm1.Button4Click(Sender: TObject);
var
AList: TFreeList;
St: TStringList;
begin
AList := TFreeList.Create;
St := TStringList.Create;
St.Add('Name=David');
St.Add('Address=144 Sands Point Dr.');
AList.Add(St);
Viewer.FormData := AList;
AList.Free;
end;
See Also