| View previous topic :: View next topic |
| Author |
Message |
SAN CAZIANO Guest
|
Posted: Thu Oct 30, 2003 1:06 pm Post subject: how can I count all TEDIT in a tabsheet |
|
|
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
|
Posted: Thu Oct 30, 2003 1:07 pm Post subject: Re: how can I count all TEDIT in a tabsheet |
|
|
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
|
Posted: Thu Oct 30, 2003 2:17 pm Post subject: Re: how can I count all TEDIT in a tabsheet |
|
|
| 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
|
Posted: Thu Oct 30, 2003 3:25 pm Post subject: Re: how can I count all TEDIT in a tabsheet |
|
|
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
|
Posted: Sat Nov 01, 2003 11:45 am Post subject: Re: how can I count all TEDIT in a tabsheet |
|
|
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
|
Posted: Sun Nov 02, 2003 6:50 pm Post subject: Re: how can I count all TEDIT in a tabsheet |
|
|
"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 |
|
 |
|