Recent

Author Topic: To count the amount of each control type  (Read 3836 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
To count the amount of each control type
« on: October 25, 2010, 01:46:01 pm »
In a form, there are lots of controls and various types.
Please help finding the way to count for each type :-[.
Thank you.
Lazarus 1.2.4 / Win 32 / THAILAND

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: To count the amount of each control type
« Reply #1 on: October 25, 2010, 01:52:40 pm »
Code: [Select]
  for i := 0 to Application.ComponentCount - 1 do
    if Application.Components[i] is TForm then
      Showmessage(TForm(Application.Components[i]).Name);

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: To count the amount of each control type
« Reply #2 on: October 25, 2010, 02:44:29 pm »
Code: [Select]
sl: TStringList;
...
sl.Clear;
for i := 0 to Components.Count - 1 do
  sl.Values(Components[i].ClassName) :=
    IntToStr(StrToIntDef(sl.Values(Components[i].ClassName), 0) + 1));

 

TinyPortal © 2005-2018