delphi如何按照控件的左右顺序来遍历窗体中的每个控件
delphi默认是按照控件添加进窗体的顺序来遍历的,
有没有哪个属性能控制这个/??
object Form1: TForm1
Left = 226
Top = 153
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 336
Top = 128
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit1'
end
object Button1: TButton
Left = 208
Top = 296
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
end
object Button2: TButton
Left = 408
Top = 272
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 1
OnClick = Button2Click
end
object Edit2: TEdit
Left = 368
Top = 32
Width = 121
Height = 21
TabOrder = 3
Text = 'Edit2'
end
object Edit3: TEdit
Left = 200
Top = 64
Width = 121
Height = 21
TabOrder = 4
Text = 'Edit3'
end
object RadioButton1: TRadioButton
Left = 128
Top = 40
Width = 113
Height = 17
Caption = 'RadioButton1'
TabOrder = 5
end
object MainMenu1: TMainMenu
Left = 232
Top = 96
end
end
、
Delphi是根据这里定义的次序进行加载的,所以此处Components[0]为Button1
如果控制焦点的话是TabOrder这个属性
以上代码对TLabel,TImage无效 对TPanel,TEdit有效
对无效的TLabel,TImage等放在TPanel容器里面,上面的代码就可以用了