Suppose I have two forms, a main form and a supporting popup form that does something specific that the main form is not designed to do. Both of these forms are acting upon the same dataset. Should I declare the dataset as static so that I don't end up having to pass a copy of the dataset to my supporting form and then pass the copy back or call some function that returns the action?
In form1.cs (main form):
static DataSet my_dataset;
// button is pushed
button1_click() {
form2.showDialog();
}
In form2.cs (supporting form, pops up and asks a question or something):
button1_click() {
form1.my_dataset.Tables[0]
.Rows[i][0
] = "Something"; // i is just an arbitrary example
}
It doesn't have to be a dataset, I guess it could just be an int or a string or whatever. Am I understanding static variables correctly? Was this their intended use? Thanks in advance for any help.
Start Free Trial