Главная страница | назад





Article #17676: How can I access a control's members by it's Name property?

 Question and Answer Database

FAQ2676C.txt   How can I access a control's members by it's Name property?
Category   :VCL
Platform    :All
Product    :C++Builder  1.x

Question:
How can I access a control's members by using it's Name property?

Answer:
Lets say you wanted to get access to the members of a control, by using the controls name property, which is of String type.
All you'll need to know is what the parent of the control is, whether a panel or a form, along with specifying the type of control, TEdit etc.... Then, iterate through the controls on the panel or form with the folloowing code:



for (ctl = 0; ctl < NewPnl->ControlCount; ctl ++) {
 if(TEdit *EB = dynamic_cast(NewPnl->Controls[ctl]))
    if (NewPnl->Controls[ctl])->Name == "AttachEB") 
       EB->Text = "New edit box text";
}



7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99