Thursday, 4 June 2009

How to enable Default Form instances (My.Forms)

Default instances make it possible to refer to an instance of a form without having to explicitly create it first. The compiler utilizes My.Forms to create default instances. By default My.Forms is available only for Windows Forms application.
My.Forms Object
http://msdn.microsoft.com/en-us/library/87y2hdsf.aspx
We can use the _MY compilation constants to change the default behavior. If you would like to enable the Forms Default Instances in a Class Library project, you can set the "_MYFORMS" compilation constant as True. We can use the following steps to implement it.
a) On the Project menu, click Properties.
b) Click the Compile tab.
c) Click Advanced.
d) Modify the value in the Custom Constants box. (Add "_MYFORMS=True")
e) Now we can see that there are no errors for “Me.MdiParent = MDIParent1”
Customizing Which Objects are Available in My
http://msdn.microsoft.com/en-us/library/ms233781.aspx
/define (Visual Basic)
http://msdn.microsoft.com/en-us/library/s477hyxw.aspx
Simplify Common Tasks by Customizing the My Namespace
http://msdn.microsoft.com/en-us/magazine/cc188706.aspx

No comments: