Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Visibility of objects, properties & methods
Message
From
04/11/2010 12:11:43
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Visibility of objects, properties & methods
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01488251
Message ID:
01488251
Views:
98
I'm struggling to understand the visibility of objects and their properties & methods in .Net, can anyone assist?

For Example;

I have a simple project with two forms "MainForm" and "SubForm", there is a button on the MainForm that calls the SubForm.

If I was in VFP I would expect the subform to be able to see the properties and methods of the MainForm, EG. MainForm.MyProperty etc. but in .Net although I can see MainForm and all base properties I can't see any of my custom ones.

Code looks like this
namespace WindowsTestApplication
{
    public partial class MainForm : Form
    {
        public int publicInt = 0;
        private string privateString = "Hello";

        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form oSubForm = new Form();
            oSubForm.Show();
        }
    }
}
namespace WindowsTestApplication
{
    public partial class SubForm : Form
    {
        public SubForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Want to reference MainForm here.
        }
    }
}
Thought in the above I would be able to see 'publicInt' but not see 'privateString', but I can't see either.

Gary.
Next
Reply
Map
View

Click here to load this message in the networking platform