I have a GroupBox
in a Form
. In this GroupBox
I have three Checkboxes
that can be checked either one, two or three. I want the checked state to maintain after I close this form and reopen it. Is it something about the GroupBox
that has to be taken into consideration? How can I do this? Thank you.
Asked
Active
Viewed 791 times
0

Vimal CK
- 3,543
- 1
- 26
- 47

Andreea Suciu
- 41
- 4
-
2Maybe if you can provide some code we can help you better. How do open the form and how do you close it? – Maximilian Riegler Apr 29 '15 at 11:12
-
[this link can probably help](https://msdn.microsoft.com/en-us/library/bb397750%28v=vs.110%29.aspx) – Zohar Peled Apr 29 '15 at 11:18
-
What do you mean by closing the form? Closing a single form and reopen it while the application remains alive or closing the whole application? – Adassko Apr 29 '15 at 11:29
-
If retention on a form is the concern, a static list from a class should help you out, if retention even the application is closed is the concern, database should help you out. – ken lacoste Apr 29 '15 at 11:29
-
see this [answer](http://stackoverflow.com/a/280586/2523942). It may help – Mord Zuber Apr 29 '15 at 11:37
-
@Andreea . You should select an answer if one of them solves this problem for you. Thanks. – Louis van Tonder Jun 10 '15 at 06:52
1 Answers
0
Create a custom class from the groupbox items. Add properties for each item, i.e. .checked
Store your object in a global variable. Before the form closes, update your global variable witht he current item structure and their checked properties.
On re-open of the form, load and prepare the groupbox from the custom object.
If your groupbox state needs to persist on application close, you will have to do the above, but use a database instead of a global variable.

Louis van Tonder
- 3,664
- 3
- 31
- 62