Hello All,
I am having a bit of a problem here and I can't seem to figure out how to fix it. Hopefully someone out there will be able to shed some light on what is going on and how to fix the problem.
I have a two project solution file. Project one is a Win Forms EXE and contains all the forms used by the application. Project two is a Class Library. The class modules are organized to form an Object Model. The model's layers, properties and methods are accessed using standard dot notation, as in clsApp.Database.InitDB. One of the properties of the class library's root class, Application, is MainForm. During the startup phase of the Win Forms application, I set clsApp.MainForm to a value of frmMain. frmMain is the main form of the application. It is an MDI Parent form. I do this to allow me to access the main form through the object model rather than access it directly. The assignment seems to function correctly other than the fact that Intellisense does not display all the form's controls, event procedures and user defined procedures. Instead what is returned by Intellisense is a listing of generic form's properties an methods.
This seems a bit strange to me because once I set clsApp.MainForm to frmMain then clsApp.MainForm should be a copy of frmMain and Intellisense should see all the controls and such just as though I were accessing frmMain directly. This may seem like a trivial matter, but I use the object model references to clsApp.MainForm in quite a few places in my application. I am particularly puzzled by the fact that this technique worked very well in VB6. I would think that .Net could handle it, no problem.
I believe what is going on is a casting problem, but for the life of me, I have no idea how to fix it. Below are the Sub Main() procedure and the MainForm property procedure. I would be most grateful if someone would be kind enough to shed some light on this problem and how to fix it.
Sub Main()ChDir(
My.Application.Info.DirectoryPath)clsApp.GetSettings()
clsApp.MainForm = frmMain
clsApp.MainForm.Text =
My.Application.Info.ProductNameclsApp.MainForm.Show()
Application.Run()
End Sub Private frmMainForm As New System.Windows.Forms.Form Public Property MainForm() As System.Windows.Forms.Form GetMainForm = frmMainForm
End Get Set(ByVal Value As System.Windows.Forms.Form)frmMainForm = Value
End Set End PropertyThanks so much in advance for the help.
V. Shane Curtis

Intellisense Does "See" all Forms Controls And Procedures
Romstyle
Hi,
Intellisense only display System.Windows.Forms.Form's properties and methods because your MainForm property returns a System.Windows.Forms.Form object.
If you change it to your main form's type Intellisense will display the main form's properties and methods.
Private frmMainForm As New <YourMainFormType>
Public Property MainForm() As <YourMainFormType>Get
MainForm = frmMainForm
End Get
Set(ByVal Value As <YourMainFormType>)
frmMainForm = Value
End Set
End Property
Best regards,
Pace_uk
Hi,
You main form is still defined as a new type derived from System.Windows.Forms.Form, so Intellisense needs that to be able to display your main form's specific public properties / methods.
This drills down to the same issue as your other post, where you want ClassLibrary to know about WinForms's Settings object without a reference to WinForms.
I can only suggest some ideas
Best regards,
Alexander Aza
Hello Again and thank you for responding to my post. My Main Form is nothing more than a standard Win Form object that has be designated as an MDI Container. It is nothing more than a modified version of the MDI Form Template that comes with Express. at heart it is nothing more than a standard form. Hence, it should work. There does not appear to be a MDIParent form in System.Windows.Forms. Hence the closest approximation is System.Windows.Forms.Form. If there is a way to resolve this casting issue I would appreciate your help. I cannot set a reference to the Win Forms project from the Class Libray project because the Win Forms project already references the Class Library project and this would produce a circular reference. In VB 6 I was able to declare the frmMain variable in the Class Library project as type MDIParent. This does not appear to be an option in .Net.
Best Regards,
V. Shane Curtis