M
Mojtaba Faridzad
Hi,
I have some forms that they need to have access to some public variables. to
solve this problem I decided to have a RootForm and all other forms are
drived from this form. I can set my public variables on this RootForm and
use them in the drived forms. sounds good? but there is a problem here. I
don't have access to the public variables in RootForm!!! the RootForm is
like this:
namespace myprog
public class RootForm : System.Windows.Forms.Form
{
public string myvar = "test";
.....
}
now the other form I defined like this:
namespace myprog
public class OtherForm : myprog.RootForm
{
....
MessageBox.Show(this, RootForm.myvar);
....
}
but I don't have access to RootForm.myvar. what's the problem and how can I
use public variable in my program?
thanks
I have some forms that they need to have access to some public variables. to
solve this problem I decided to have a RootForm and all other forms are
drived from this form. I can set my public variables on this RootForm and
use them in the drived forms. sounds good? but there is a problem here. I
don't have access to the public variables in RootForm!!! the RootForm is
like this:
namespace myprog
public class RootForm : System.Windows.Forms.Form
{
public string myvar = "test";
.....
}
now the other form I defined like this:
namespace myprog
public class OtherForm : myprog.RootForm
{
....
MessageBox.Show(this, RootForm.myvar);
....
}
but I don't have access to RootForm.myvar. what's the problem and how can I
use public variable in my program?
thanks