循环访问某些控件 [英] Loop through certain controls
问题描述
我有以下循环:
Dim objPanel作为面板
每个objPanel In Me.Controls
''在这里做点什么
下一页
我的循环遇到一个不是a的控件时收到错误小组
控制。
我只想对我的表格上的Panel控件执行操作,并跳过任何
其他类型的控制。
有没有办法只通过Panel控件循环?
I have the following loop:
Dim objPanel As Panel
For Each objPanel In Me.Controls
''do something here
Next
I receive an error when my loop encounters a control that is not a Panel
control.
I only want to perform actions on the Panel controls on my form and skip any
other type of control.
Is there a way to loop only through the Panel controls?
推荐答案
Dim objPanel As对象
For Me.Controls中的每个objPanel
如果objPanel.GetType是GetType(Panel)那么
''做某事这里
结束如果
下一页
-
Greetz,
Jan
__________________________________
阅读我的博客: http://weblogs.asp.net/jan
Ke vin L < no_spam@not_real_email.com> schreef在bericht
新闻:uf ************** @ tk2msftngp13.phx.gbl ...
Dim objPanel As Object
For Each objPanel In Me.Controls
If objPanel.GetType Is GetType(Panel) Then
''do something here
End If
Next
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Kevin L" <no_spam@not_real_email.com> schreef in bericht
news:uf**************@tk2msftngp13.phx.gbl...
我有以下循环:
Dim objPanel作为面板
每个objPanel In Me.Controls
''在这里做点什么
接下来
我的循环遇到一个不是Panel
控件的控件时收到错误。
我只想对表单上的Panel控件执行操作并跳过
任何其他类型的控件。
有没有办法只通过Panel控件循环?
I have the following loop:
Dim objPanel As Panel
For Each objPanel In Me.Controls
''do something here
Next
I receive an error when my loop encounters a control that is not a Panel
control.
I only want to perform actions on the Panel controls on my form and skip any other type of control.
Is there a way to loop only through the Panel controls?
Kevin,
Kevin,
有没有办法只通过Panel控件循环?
Is there a way to loop only through the Panel controls?
For Each ctl作为Control In Me.Controls
如果TypeOf ctl是Panel那么
objPanel = CType(ctl,Panel)
''在这里做点什么
结束如果
下一页
Mattias
-
Mattias Sj?g ren [MVP] mattias @ mvps.org
http://www.msjogren。 net / dotnet / | http://www.dotnetinterop.com
请回复到新闻组。
For Each ctl As Control In Me.Controls
If TypeOf ctl Is Panel Then
objPanel = CType(ctl, Panel)
''do something here
End If
Next
Mattias
--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
你必须做这样的事情(来自记忆中的goiung)
Dim objPanel作为控制
For Me.Controls中的每个objPanel
如果objPanel是Panel那么
''在这里做点什么
结束如果
下一页
HTH
Brian W
Kevin L < no_spam@not_real_email.com>在消息中写道
news:uf ************** @ tk2msftngp13.phx.gbl ...
You will have to do something like this (goiung from memory)
Dim objPanel As Control
For Each objPanel In Me.Controls
If objPanel Is Panel Then
''do something here
End If
Next
HTH
Brian W
"Kevin L" <no_spam@not_real_email.com> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
我有以下循环:
Dim objPanel作为面板
每个objPanel In Me.Controls
''在这里做点什么
接下来
我的循环遇到一个不是Panel
控件的控件时收到错误。
我只想对表单上的Panel控件执行操作并跳过
任何其他类型的控件。
有没有办法只通过Panel控件循环?
I have the following loop:
Dim objPanel As Panel
For Each objPanel In Me.Controls
''do something here
Next
I receive an error when my loop encounters a control that is not a Panel
control.
I only want to perform actions on the Panel controls on my form and skip any other type of control.
Is there a way to loop only through the Panel controls?
这篇关于循环访问某些控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!