Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 09-20-2012, 03:03 PM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Question XE2 using FindComponent to get TMemo Text

I have the following code which creates a number of Tabsheets on a PageControl (pcWHHPPartners) and adds a memo to each sheet called Notes1,2,3,4..... 'i' is the loop variable.

Code:
tabSheet:=TTabSheet.Create(form1.pcWHHPpartners) ;
tabSheet.PageControl:=form1.pcWHHPpartners;
tabSheet.Name:='WHHPNotes'+inttostr(i);
tabSheet.Caption:=cap(StringReplace(whhpPartners[i].whhpOrg, '&', '&&', [rfReplaceAll]));
tabSheet.TabVisible:=false;
tabsheet.enabled:=true;

mmo := TMemo.Create(tabSheet);
mmo.Align := alClient;
mmo.Parent := tabSheet;
mmo.Visible := True;
mmo.align:=alClient;
mmo.enabled:=true;
mmo.Name:='Notes'+inttostr(i);
//mmo.MaxLength:=254;
mmo.Clear;
What I am trying to achieve is to pass a function the number of the memo and retrieve the text from that memo, however when trying to use examples from the web showing how to use the FindComponent function, They all seem to show examples for older delphi's.

Could anybody help me out with some code?

This is what I have got from somebody already
Code:
TPageControl(FindComponent('Notes'+inttostr(p)As TMemo).ToString;
  #2  
Old 09-20-2012, 03:21 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

a TMemo typecasted as TPageControl???

Why not
Code:
TMemo(FindComponent('Notes'+inttostr(p))).Lines.Text

Last edited by Norrit; 09-20-2012 at 03:23 PM.
  #3  
Old 09-20-2012, 05:32 PM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Default I am getting an Undefined Identifier

'FindComponent' is coming up as an Undefined identifier

Code:
TMemo(FindComponent('Notes'+inttostr(p))).Lines.Text
  #4  
Old 09-21-2012, 08:42 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

Then in your original code FindComponent would've raised the same compile error
Where is that message in your original topic???
  #5  
Old 09-21-2012, 10:25 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

But the answer is as simple as form1.FindComponent
In the future try to give the exact problem you're running into, this will give you quicker and far more accurate answers
  #6  
Old 10-27-2012, 03:23 PM
emailx45 emailx45 is offline
Junior Member
 
Join Date: May 2012
Posts: 18
Thumbs up

If you use TabSheet, see the ACTIVE propertie and the MEMO in.

Ex.: cmpTABSHeet.active.components.count (FOR NEXT)
if cmpTABSHeet.active.components[i] is tmemo
xx:= cmpTABSHeet.active.components[i]
(xx as tmemo).text
Closed Thread

Tags
findcomponent, retrieve, text, tmemo, xe2

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:16 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.