Patrick <Pa*****@discussions.microsoft.com> wrote:
My code looks like this:
public class FrmMain : System.Windows.Forms.Form
{
.
.
public DataAccess myDataAccessor;
.
.
public FrmMain()
{
VerifyDelete = true;
DataAccess myDataAccessor = new DataAccess();
Event myEvent = new Event();
InitializeComponent();
InitializeForm();
.
.
.
}
And InitializeForm has the following signature:
public void InitializeForm()
When I'm in frmMain, after the myDataAccessor and myEvent objects are
instatiated, the objects are accessible. As soon as I enter
InitializeForm, the objects report <undefined value> in the watch
window.
Does this give further clarification? I don't see anywhere I'm
misusing the functions.
Again, it's not an accessibility problem. The problem (as I suggested
in my last post) is that you've redeclared your myDataAccessor
variable.
Instead of
DataAccess myDataAccessor = new DataAccess();
(which is declaring a new local variable and assigning it a value) you
should have
myDataAccessor = new DataAccess();
(which sets the value of the *instance* variable myDataAccessor).
Same for myEvent.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too