请问:如何遍历窗体tab控件或group控件中包含的所有控件?谢谢!

haikuotiankong 2007-04-13 02:49:28
如题。
...全文
279 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
huming_h 2007-04-16
  • 打赏
  • 举报
回复
foreach(Control control in this.Controls )
{
if(control is TabControl)
{
foreach(Control lbl in control )
{
...
}

}
BrillianZhang 2007-04-16
  • 打赏
  • 举报
回复
foreach (Control CtlTabPage in xtctl.Controls)
{
if (CtlTabPage is DevExpress.XtraTab.XtraTabPage)
{
foreach (Control CtlGB in ((DevExpress.XtraTab.XtraTabPage)CtlTabPage).Controls)
{
if (CtlGB is System.Windows.Forms.GroupBox)
{
foreach (Control CtlFLP in ((System.Windows.Forms.GroupBox)CtlGB).Controls)
{
……
}
}
}
}
}
haikuotiankong 2007-04-16
  • 打赏
  • 举报
回复
怎么没有人回答呢?!!...
we157438366 2007-04-13
  • 打赏
  • 举报
回复
foreach(Control control in this.Controls )
{
if(control is TabControl)
{
foreach(control.Control lbl in control )//这个地方这么写不对,该怎样写呢?
{
...
}

}

haikuotiankong 2007-04-13
  • 打赏
  • 举报
回复
foreach(Control control in this.Controls )
{
if(control is TabControl)
{
foreach(Control lbl in control )//这个地方这么写不对,该怎样写呢?
{
...
}

}


}
txwd0033 2007-04-13
  • 打赏
  • 举报
回复
ls正解,可是怎么用vb写的?
Tom1984 2007-04-13
  • 打赏
  • 举报
回复
private sub GetCtrl(ParentCtrl as Control)
dim ctrlC as control
for each ctrlC in ParentCtrl.controls
...
If (TypeOf ctrlC Is Panel) OrElse _
(TypeOf ctrlC Is GroupBox ) Then
GetCtrl(ctrlC) '''''''''''''''''
End If
...
next
end sub

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧