I would like to better understand how class structure controls how I can access the objects it contains. Here is some test code. The method called "normal()" can access dataGridView1 but the other two cannot.
Is there a way for the other two methods to access the datagridview?
C#:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void normal(int r)
{
DataGridViewRow row = dataGridView1.Rows[r];
}
public class inside
{
public void nested(int r)
{
DataGridViewRow row = dataGridView1.Rows[r];
}
}
}
public class outside
{
public void other(int r)
{
DataGridViewRow row = Form1.dataGridView1.Rows[r];
}
}
Is there a way for the other two methods to access the datagridview?