Mega Code Archive

 
Categories / Delphi / VCL
 

Get a count and list all the controls on a TNoteBook

Title: Get a count and list all the controls on a TNoteBook 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;