一. AnsiString nameString("TButton"); TButton * button; for(int i=0; i < ComponentCount; i++)8 g# F7 v* w: I1 l {/ \5 @/ z! H# o4 A- b //Check to see if the component is a TButton: ]6 L3 S5 K7 ~8 J# Z$ d if (Components->ClassNameIs(nameString))5 e5 s% T& K8 k" ?, K1 U { //cast the component to a TButton *9 O) i. G! ^( W! N0 ^1 B4 s- n, W button = (TButton *)Components;. J; G, |" S# u& E button->Font->Name = "Courier"; ......
二. 我想动态创建和静态创建都没有太大区别,只要它属于你的MainForm。( new TButton(this) ). 用一个需循环 TButton* button; for(int i=0;i<MainForm->ComponentCount;i++){ if((button= dynamic_cast<TButton*>(MainForm->Components)) != NULL )6 r9 [# x% J2 f8 l2 {4 ? button->Caption="Button";; t/ t& E |+ n8 h3 g( `( K3 | }
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |