Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

count ttables from another form in a component

Posted on 1999-07-06
10
Medium Priority
?
187 Views
Last Modified: 2010-04-06
I have a main form with some ttable comp on and a button
when I click on the button a new form display.
on the new form there is a custom component I wrote.
in the custom component I want to count how many ttable is on the main form
i know to get ttables from the same form where the component is

 for i := 0 to Owner.ComponentCount-1 do      
 Begin                                        
   If Owner.Components[I] is TTable then      
   Begin                                      
      NoTables := NoTables + 1;                
   End;                                        
 End;  

but not from a other form
0
Comment
Question by:delpro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1386624
hi delpro,

replace
Owner.
with
Application.MainForm.

meikl
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1386625
You can use the variable name of any form Form1.ComponentCount, Form2.ComponentCount, etc. Just make sure the unit is in the other uses section and that the form has been created.
0
 
LVL 4

Expert Comment

by:Radler
ID: 1386626
if your button and your code sites in the cited form then no there sense use

Owner in your procedure, try:

for i := 0 to Owner.ComponentCount-1 do        
Begin                                          
      If Owner.Components[I] is TTable then Begin                                        
            NoTables := NoTables + 1;                
             End;
End;    

T++, Radler.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Radler
ID: 1386627
if your button and your code sites in the cited form then no there sense use

Owner in your procedure, try:

for i := 0 to Owner.ComponentCount-1 do        
Begin                                          
      If Owner.Components[I] is TTable then Begin                                        
            NoTables := NoTables + 1;                
             End;
End;    

T++, Radler.
0
 
LVL 4

Expert Comment

by:Radler
ID: 1386628
if your button and your code sites in the cited form then no there sense use

Owner in your procedure, try:

for i := 0 to Owner.ComponentCount-1 do        
Begin                                          
      If Self.Components[I] is TTable then Begin                                        
            NoTables := NoTables + 1;                
             End;
End;    

T++, Radler.
0
 
LVL 4

Expert Comment

by:Radler
ID: 1386629
Sorry,

My proxie server is very complicated.
Consider the last.

T++, Radler.
0
 

Expert Comment

by:kwang080897
ID: 1386630
Hi Radler !!!!

I used to have the same problem with my proxy......

Never use Refresh after posting a form, (I bet you get promptet if you wanne resubmit data - or something like that)

Sorry for Interfering !!!!
0
 

Author Comment

by:delpro
ID: 1386631
I have found a way to count all the TTables in my form
just what i want
thanks kretzschmar for the tip
If you know a better way can you anser the Q for the points


0
 
LVL 4

Expert Comment

by:Radler
ID: 1386632
A simple warning, Application.MainForm is the same that Self, if your form owner of this button is demote to be a non "Main" Form back to use "Self".
In my codes to avoid conflit I always use "self" with excess.

T++, Radler.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 1386633
hi delpro,

a other way is to walk through the forms until a condition is matched
you can by this also count all ttables of the app

sample

var I,J : Integer;
begin
  J := 0;
  While (J < Screen.FormCount) and
        (Screen.Forms[J].AProperty <> MyCondition) do Inc(J);
  If J < Screen.FormCount then
  begin
    for i := 0 to Screen.Forms[J].ComponentCount-1 do
      If Screen.Forms[J].Components[I] is TTable then
        NoTables := NoTables + 1;
  end;
end;

hope this helps a little

meikl
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question