Open a dynamic form dynamically, winforms
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()
精彩评论