通过这个例子深入了解组件的表示方法,如何判断窗体中的组件属于某类组件(如是否为文本框:is tedit,如果想让按钮灰显应该是if Components[i] is Tbutton吧)。更重要的是通过这个例子我们可以了解组件和容器的关系:父子关系
procedure TForm1.Button1Click(Sender: TObject);
var i: integer; begin for i:=0 to ComponentCount-1 do begin if Components[i] is TEdit then begin if TEdit(Components[i]).Parent = Panel2 then TEdit(Components[i]).ReadOnly := True; end; end; end; |
|
来自: jojo1981 > 《Delphi编程》