Главная страница | назад





Article #15984: Get a count and list all the controls on a TNoteBook

 Question and Answer Database

FAQ984D.txt   Get a count and list all the controls on a TNoteBook
Category   :VCL
Platform    :All
Product    :All 32 bit  

Question:
How can I get a count and list all the controls on a TNoteBook
component?

Answer:
The following example demonstrates getting a list of the pages in
a TNotebook component, and listing the controls on each page of the
Notebook component. The list is added into a Listbox component.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  n: integer;
  p: integer;
begin
  ListBox1.Clear;
  with Notebook1 do begin
    for n := 0 to ControlCount - 1 do begin
      with TPage(Controls[n]) do begin
        ListBox1.Items.Add('Notebook Page: ' +
                           TPage(Notebook1.Controls[n]).Caption);
        for p := 0 to ControlCount - 1 do
          ListBox1.Items.Add(Controls[p].Name);
        ListBox1.Items.Add(EmptyStr);
      end;
    end;
  end;
end;

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99