Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Windows Form by its class name

I am actually studying and working on VB.NET. My school is using VS2010, and I professionally use VS2012. When I have to call a windows form in an Mdicontainer in VS2010, I just use its class name, like for example:

FormX.MdiParent = Me

FormX.Show()

But when i use VS2012, it seems I have to create an instance of my mdichild, just like this:

Dim form As New FormX()

form.MdiParent = Me

form.Show()

My question is: is it just me doing wrong or VS has changed the way we use WinForms?

like image 891
Yonn Trimoreau Avatar asked Aug 20 '13 13:08

Yonn Trimoreau


1 Answers

VS2012 VB.NET does have default instances, just like in VS2010. Most likely you have defined a custom Sub New() with a parameter list, e.g. Sub New(a As Integer). When this is the case no default instance is generated, you need to explicitly create the form.

like image 52
SSS Avatar answered Oct 21 '22 21:10

SSS