我有一个单一TForm的TVertScrollBox。我已经添加了 6TPanels作为 this 的孩子TVertScrollBox。
我想遍历每个面板并检查每个面板的Tag属性,但我找不到正确的方法。
为了进行测试,我OnClick为其中一个面板添加了一个事件处理程序,其中包含以下代码:
void __fastcall TForm1::Panel1Click(TObject *Sender)
{
int i;
for (i = 0; i < this->VertScrollBox1->ChildrenCount; ++i)
{
ShowMessage("Child: " + this->VertScrollBox1->Children[i]->Name);
}
for (i = 0; i < this->VertScrollBox1->ComponentCount; ++i)
{
ShowMessage("Component: " + this->VertScrollBox1->Components[i]->Name);
}
}
似乎该ChildrenCount属性总是返回2,并且每个子项的Name显示 byShowMessage是一个空字符串,即使每个面板都有一个唯一的Name属性。
该ComponentCount属性始终返回1,并且再次显示Name始终为空字符串。
有人能告诉我使用哪些属性或方法来迭代这些孩子吗?