The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,119 other followers

Archive for May 12th, 2009

Delphi – more for … in support for TComponent.Components using a class helper

Posted by jpluimers on 2009/05/12

With my blog posting last week on Delphi – class helper to add for … in support for TComponent.Components/ComponentCount  I ‘lied’ a bit. 

What I actually wanted to do was write code like this:

  for Component in Self.ComponentsOfType(TSQLQuery) do
    (Component as TSQLQuery).SQL[1] := FTableName;

This filters the enumeration to only enumerate components that are of type TSQLQuery or descend from type TSQLQuery.

So I wanted to write a ‘richer’ enumerator than just iterating over all components.
The scond part of the lie is that such an enumerator in fact already exists: there is already a TComponent.GetEnumerator method.
Primoz Gabrijelcic’s – web/blog – rightly noted in the comment where he pointed to a similar blog post he wrote for TControls.

Since I wrote this post last week as well, but scheduled to be published right before DelphiLive!, I just added a reference to his comment, site, blog and posting.

TComponent already has a GetEnumerator since Delphi 2006.
But my TComponentEnumerator was meant as a base class to show you how to descend from it.
And that’s what this blog post is about.
Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: