Reference to a non-shared member requires an object reference
Posted on 2006-04-06
I have an application with two forms, in which the following occurrs:
1. MainForm opens ChildForm.
2. Before ChildForm closes it should call to a sub in MainForm.
3. This sub should take parameters passed from ChildForm and populate a TreeView within MainForm.
This worked fine when the project was configured as a Windows Application. However, it has become necessary to change this to a Class Library. After doing so, the call to the sub in MainForm errors out with "Reference to a non-shared member requires an object reference". If I change the sub to Public Shared, it cannot manipulate the control it is supposed to populate. I tried creating an object reference from the ChildForm as it suggests but when I step through the code, it seems to work but nothing populates in the TreeView.
Any help will be extremely helpful. Thanks!
Public Class MainForm
' Populate the TreeView with the data from ChildForm
Private Sub GetInfoFromChildForm(ByVal Info as string)
Public Class ChildForm
' Pass the info to MainForm
Private Sub PassInfo()
' Call the sub in MainForm that populates the MainForm TreeView