如何将工程中所有的窗体遍历出来

viptiger 2003-03-21 05:13:01
加精
时了很多方法不行,望大家帮忙
...全文
66 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
viptiger 2003-03-21
  • 打赏
  • 举报
回复
If tpe.BaseType.ToString = "System.Windows.Forms.Form" Then

但是一定要这样才可以取到积累
viptiger 2003-03-21
  • 打赏
  • 举报
回复
上面的方法可以遍历包括窗口的所有工程类了

谢谢几位大侠的指点:)
viptiger 2003-03-21
  • 打赏
  • 举报
回复
timmy3310(tim) 大侠这样就已经可以遍历出来了
感激
Dim a As System.Reflection.Assembly
a = System.Reflection.Assembly.GetExecutingAssembly()

Dim types As Type()
types = a.GetTypes()

Dim tpe As Type

For Each tpe In types
MessageBox.Show(tpe.Name)
Next
自由之眼 2003-03-21
  • 打赏
  • 举报
回复
谢谢大侠们
Latitude 2003-03-21
  • 打赏
  • 举报
回复
看一下我的专栏:
http://www.csdn.net/develop/author/netauthor/Latitude/
中的:Henry手记-VB.net WinForm中的FORM初探(三)
一文,关于forms的运用。
---
good luck!
by Henry
timmy3310 2003-03-21
  • 打赏
  • 举报
回复
to free_eyes(eyes):

谢谢,没注意

不好意思
If t Is Form Then
这一句
请改成:
If t.IsSubclassOf( Type.GetType("Form") ) Then
自由之眼 2003-03-21
  • 打赏
  • 举报
回复
t Is Form 命名不匹配啊
timmy3310 2003-03-21
  • 打赏
  • 举报
回复
Dim asm As System.Reflection.Assembly
asm = System.Reflection.Assembly.GetExecutingAssembly()

Dim types As Type()
types = asm.GetTypes()

Dim t As Type

For Each t In types
If t Is Form Then
'you can create a instance to do something,like :
Dim frm As Form
frm = Activator.CreateInstance(t)
frm.Show()
End If
Next
山顶洞人-平 2003-03-21
  • 打赏
  • 举报
回复
楼上,我要的是在VB.NET中的方法,谢谢
timmy3310 2003-03-21
  • 打赏
  • 举报
回复
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

Type[] types = assembly.GetTypes();
foreach( Type t in types )
{
if( t is Form )
//you can create a instance to do something,like :
{
Form frm = Activator.CreateInstance( t );
frm.Show();
}
}

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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