BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how can I count all TEDIT in a tabsheet

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
SAN CAZIANO
Guest





PostPosted: Thu Oct 30, 2003 1:06 pm    Post subject: how can I count all TEDIT in a tabsheet Reply with quote



how can I count all TEDIT in a tabsheet ???

I have used this but it is always 0

var
i,Tot:integer;
begin
Tot:=0;
for i:=0 to Tab.ComponentCount-1do
if Tab.Components[i].ClassNameis('TEDIT')then
inc(Tot);
Result:=tot;


Back to top
Mike Williams (TeamB)
Guest





PostPosted: Thu Oct 30, 2003 1:07 pm    Post subject: Re: how can I count all TEDIT in a tabsheet Reply with quote



On 30 Oct 2003, "SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote:

Quote:

how can I count all TEDIT in a tabsheet ???

I have used this but it is always 0

var
i,Tot:integer;
begin
Tot:=0;
for i:=0 to Tab.ComponentCount-1do
if Tab.Components[i].ClassNameis('TEDIT')then
inc(Tot);
Result:=tot;

Try this instead:

for i:=0 to Tab.ControlCount-1 do
if Tab.Controls[i] is tEdit then
inc(Tot);

--
-Mike (TeamB)

Back to top
Marc Rohloff
Guest





PostPosted: Thu Oct 30, 2003 2:17 pm    Post subject: Re: how can I count all TEDIT in a tabsheet Reply with quote



Quote:
Try this instead:

for i:=0 to Tab.ControlCount-1 do
if Tab.Controls[i] is tEdit then
inc(Tot);

This code will only count edits placed directly on the tab sheet. Not
those that are placed inside a panel or groupbox (or something else) on
the tabsheet.

Marc

Back to top
John Leavey
Guest





PostPosted: Thu Oct 30, 2003 3:25 pm    Post subject: Re: how can I count all TEDIT in a tabsheet Reply with quote

On Thu, 30 Oct 2003 14:06:42 +0100, "SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote:

Quote:
how can I count all TEDIT in a tabsheet ???


// tests to see if C1 has C2 as a parent (or indirect parent)
function IsChild( C1, C2: TControl ): Boolean;
begin
Result := C1.Parent = C2;

if not Result and Assigned( C1.Parent ) then
Result := IsChild( C1.Parent, C2 );
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i, EditCount: Integer;
begin
EditCount := 0;
for i := 0 to ComponentCount - 1 do
begin
if ( Components[ i ] is TEdit ) and
IsChild( TEdit( Components[ i ] ), TabSheet1 ) then
Inc( EditCount );
end;

ShowMessage( IntToStr( EditCount ) + ' TEdits on PageControl' );
end;


John Leavey

Back to top
Borland
Guest





PostPosted: Sat Nov 01, 2003 11:45 am    Post subject: Re: how can I count all TEDIT in a tabsheet Reply with quote

try this one.

var
i: integer;
count: integer;
begin
count := 0;
for i := 0 to ComponentCount - 1 do
if Components[i] is TWinControl then
if IsChild(TabSheet1.Handle, TWinControl(Components[i]).Handle) then
count := count + 1;
ShowMessage(IntToStr(count));
end;


bye
Jean



Back to top
Joost Molenaar
Guest





PostPosted: Sun Nov 02, 2003 6:50 pm    Post subject: Re: how can I count all TEDIT in a tabsheet Reply with quote

"SAN CAZIANO" schreef...
Quote:
I have used this but it is always 0

if Tab.Components[i].ClassNameis('TEDIT')then

If .ClassNameIs just compares strings, 'TEDIT' and 'TEdit' will not be the
same, and that would be why the function returns 0. I think changing 'TEDIT'
to 'TEdit' should solve it.

JOoSt



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.