如何循环tabcontrol1或tabpage中的所有控件?

编程入门 行业动态 更新时间:2024-10-20 20:47:16
本文介绍了如何循环tabcontrol1或tabpage中的所有控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

For Each cControl In Me.Controls If (TypeOf cControl Is TextBox) Then End If If (TypeOf cControl Is CheckBox) Then End If If (TypeOf cControl Is ComboBox) Then End If If (TypeOf cControl Is RadioButton) Then End If next cControl

我尝试了什么: 尽我所能努力提高质量但是?

What I have tried: tryed me best effort to make a quality but ?

推荐答案

不太确定您的问题,因为您显示的代码将起作用,但是如果您在像tabcontrol这样的容器中有控件,则需要单独迭代这些控件,因为它们不是你正在迭代的容器。 最简单的方法是使用一个递归函数将容器控件作为参数传递,当它发现一个控件让子控件传递给控件时调用它自己争论。 快示例(未经过我头脑的测试)。 Not quite sure of your question as the code you show will work, however if you have controls inside a container like a tabcontrol you need to iterate those controls separately as they are not members of the container you are iterating. Easiest way is to use a recursive function passing the container control as argument and calling itself when it find a control has children passing that control as argument. Quick example (not tested written of the top of my head). public sub WalkControls(TopControl as Control) For Each x As Control In TopControl.Controls If x.HasChildren Then WalkControls(x) Else ' ' Do what you want to do with the control ' End If Next End sub

更多推荐

如何循环tabcontrol1或tabpage中的所有控件?

本文发布于:2023-11-06 13:48:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   tabpage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!