0
我有一個單獨的TForm
單個TVertScrollBox
。我已添加6 TPanels
作爲此TVertScrollBox
的子女。迭代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
,併爲每個顯示由ShowMessage
的Name
這些孩子是一個空字符串,即使每個面板都有一個獨特的Name
屬性。
ComponentCount
屬性始終返回1
,並且再次顯示的Name
始終是空字符串。
有人能告訴我使用哪些屬性或方法來遍歷這些孩子嗎?
完美! 'TVertScrollBox'對象報告兩個孩子:'TLayout'和'TScrollContent'類型的對象。我所有的面板都是TScrollContent對象的子元素。謝謝 – ardnew 2012-04-24 20:25:26