Możesz tylko wystawić stan CheckBoxes Checked poprzez właściwości tego formularza, w którym umieścisz CheckBoxe i uzyskać dostęp do tych właściwości z trzeciego formularza lub Formularza procesu.
public partial class MainForm : Form {
// We assume we have let's say three CheckBoxes named chkFirst, chkSecond and chkThird
public bool IsFirstChecked { get { return chkFirst.Checked; } }
public bool IsSecondChecked { get { return chkSecond.Checked; } }
public bool IsThirdChecked { get { return chkThird.Checked; } }
// Calling this form from where these checked states will be processed...
// Let's suppose we have to click a button to launch the process, for instance...
private void btnLaunchProcess(object sender, EventArgs e) {
ProcessForm f = new ProcessForm();
f.Parent = this;
if (DialogResult.OK == f.ShowDialog()) {
// Process accordingly if desired, otherwise let it blank...
}
}
}
public partial class ProcessForm : Form {
// Accessing the checked state of CheckBoxes
private void Process() {
if ((this.Parent as MainForm).FirstChecked)
// Process according to first CheckBox.Checked state.
else if ((this.Parent as MainForm).SecondChecked)
// Process according to second CheckBox.Checked state.
else if ((this.Parent as MainForm).ThirdChecked)
// Process according to third CheckBox.Checked state.
}
}
Proszę zwrócić uwagę, że wybrałem ten kod się w mojej głowie, więc może się zdarzyć, nie skompilować. W każdym razie, mam nadzieję, że to daje ci wyobrażenie, jak przekazywać wartości w swoich formularzach.
Największą różnicą między programowaniem w sieci i WinForm jest to, że sieć Web jest bezstanowa. SESJA i VIEWSTATE to obejścia pozwalające zachować wartości.
WinForm są stanowe, więc nie trzeba przechodzić przez SESJĘ i zmienne podobne do VIEWSTATE. Wartość jest zachowywana, o ile obiekt istnieje.
Pomoże Ci to, jeśli możesz podać przykład tego, co próbujesz osiągnąć.Czy chcesz przechowywać wartości dla pojedynczego użytkownika w "sesji" i czy dane mają przetrwać cały cykl życia? –