开发者

Open a dynamic form dynamically, winforms

开发者 https://www.devze.com 2023-04-03 14:26 出处:网络
My main class has following function: sub openform(formnum as integer) dim obj as Form select case formnum

My main class has following function:

sub openform(formnum as integer)

dim obj as Form

select case formnum
case 0
obj=new form0
case 1
obj=new form1
case 2
obj=new form2
case 3
obj=new form3
end select

obj.showdialog()

end sub

so the param 'formnum' will be coming from command line args.

In the future I may have 1000 forms, so I need to write 1000 cases to open 开发者_如何学JAVAthe required form.

Instead of that, is there any alternate way to open a form??

something like:

dim obj as form=application.findforms("form" & formnum)
obj.showdialog()


Maybe this will work?

Dim f As Form = DirectCast(Activator.CreateInstance(Me.GetType().Assembly.FullName, "[namespace].form" & formnum), Form)
f.ShowDialog()
0

精彩评论

暂无评论...
验证码 换一张
取 消