为什么要使用DelphiVCL的Application.ComponentIndex?

112 阅读1分钟

DelphiVCLComponentIndex属性或DelphiVCL.Application.ComponentIndex 用于指示组件在其所有者的Components属性阵列中的位置。

在迭代组件所有者的组件列表时,使用ComponentIndex来对拥有的组件进行操作。它可以和ComponentCount一起使用。ComponentIndex在内部用于迭代分配程序。

注意: 列表中的第一个组件的ComponentIndex值为0,第二个组件的值为1,以此类推。因此,当使用ComponentIndex与ComponentCount时,注意ComponentCount总是比最高的Component指数多1。

让我们用dir()命令浏览DelphiVCL.Application.ComponentIndex的所有属性和方法。

import DelphiVCL

dir(DelphiVCL.Application.ComponentIndex)

请看我们的Windows命令提示符中的反应。

Why Would You Use Application.ComponentIndex From DelphiVCL? The built in properties and methods listing.

你也可以使用print()命令来阅读DelphiVCL.Application. ComponentIndex的简短信息。

print(DelphiVCL.Application.ComponentIndex)
print(DelphiVCL.Application.ComponentIndex.__doc__)

请看我们的Windows命令提示符中的响应。

Why Would You Use Application.ComponentIndex From DelphiVCL? Showing the reposnses from the command.