C# 在TableLayoutPanel中查找元素
我正处于c#的学习阶段 我想在TableLayoutPanel中添加所有标签C# 在TableLayoutPanel中查找元素,c#,winforms,tablelayoutpanel,C#,Winforms,Tablelayoutpanel,我正处于c#的学习阶段 我想在TableLayoutPanel中添加所有标签 Control c2 = this.ReportTable.GetControlFromPosition(col,row+1); Trace.WriteLine(c2.GetType()); if (c2.GetType().Equals(typeof(TableLayoutPanel))) { // Put loop to iterate. } ReportTable也是TableLayoutPane
Control c2 = this.ReportTable.GetControlFromPosition(col,row+1);
Trace.WriteLine(c2.GetType());
if (c2.GetType().Equals(typeof(TableLayoutPanel)))
{
// Put loop to iterate.
}
ReportTable也是TableLayoutPanel
c2.GetType()
正在给出TableLayoutPanel
。我无法将RowCount
方法应用于c2.GetType().RowCount
请帮助我在
TableLayoutPanel
中迭代,该面板位于其他TableLayoutPanel
中,包含其他元素我想,没关系。我本来打算做打字来控制
Control c2 = this.ReportTable.GetControlFromPosition(col,row+1);
Trace.WriteLine(c2.GetType());
if (c2.GetType().Equals(typeof(TableLayoutPanel)))
{
TableLayoutPanel tp = (TableLayoutPanel)c2;
// get all labels in table
foreach(Control ctr in tp.Controls){
Trace.WriteLine(ctr .GetType());
}
}
@亚历克斯:谢谢,亚历克斯。我想你没有仔细阅读问题描述。我知道如何在TableLayoutPanel中交互。我无法在TableLayoutPanel 1内迭代,该面板与其他元素一起位于TableLayoutPanel内。