如果在 TabControl 或 Panel 中查找 Control,Form.Controls 将返回 Nothing

编程入门 行业动态 更新时间:2024-10-21 10:12:48
本文介绍了如果在 TabControl 或 Panel 中查找 Control,Form.Controls 将返回 Nothing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

I converted a project from vb6 to vb where I found a given control that was inside a TabControl via the collection Controls as such

Frm.Controls("ControlName")

I checked and the control does exist in the form.

I iterated on all that is inside the Controls Collection and the control is not there, only the TabControl which contains it. Does it mean that in vb I have to design a function to do something that vb6 could do?

解决方案

You can use Me.Controls.Find("name", True) to search the form and all its child controlsto find controls with given name. The result is an array containing found controls.

For example:

Dim control = Me.Controls.Find("textbox1", True).FirstOrDefault() If (control IsNot Nothing) Then MessageBox.Show(control.Name) End If

更多推荐

如果在 TabControl 或 Panel 中查找 Control,Form.Controls 将返回 Nothing

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

发布评论

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

>www.elefans.com

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