Hi…:)
I’ve got over than 120 groupboxes in my project which Contains radio buttons & Checkboxes control…
How can I save & retrieve the selection setting for these huge amounts of groupboxes when close my form and restart it? :confused:
Regards…
Printable View
Hi…:)
I’ve got over than 120 groupboxes in my project which Contains radio buttons & Checkboxes control…
How can I save & retrieve the selection setting for these huge amounts of groupboxes when close my form and restart it? :confused:
Regards…
You could go to the properties for each radiobutton, and on the application settings area (at the top) add a new setting for the 'checked' value. This will save the check states on app exit, and then retrieves them on next run.
Same for the checkboxes,.
DragonRoses' advice is sound for the CheckBoxes but you may find that you have issues doing that with the RadioButtons. If that's so, you can still use My.Settings to store the data but you can't bind it. In that case, I'd define an enumeration and store one value for each group of RadioButtons.
The following code assumes that the type of My.Settings.Skill1 and My.Settings.Skill2 is your Skill type.I included the None value in the enumeration so that no RadioButton would be checked initially. If you want to check a default RadioButton in each group then you may not need that. It's always a good idea to at least consider having the zero value in an enumeration equal to None, Unknown or the like in case there will be times that you need no value to be selected.vb.net Code:
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.skill1AverageOption.Checked = (My.Settings.Skill1 = Skill.Average) Me.skill1GoodOption.Checked = (My.Settings.Skill1 = Skill.Good) Me.skill1ExcellentOption.Checked = (My.Settings.Skill1 = Skill.Excellent) Me.skill2AverageOption.Checked = (My.Settings.Skill2 = Skill.Average) Me.skill2GoodOption.Checked = (My.Settings.Skill2 = Skill.Good) Me.skill2ExcellentOption.Checked = (My.Settings.Skill2 = Skill.Excellent) End Sub Private Sub skill1AverageOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill1AverageOption.CheckedChanged My.Settings.Skill1 = Skill.Average End Sub Private Sub skill1GoodOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill1GoodOption.CheckedChanged My.Settings.Skill1 = Skill.Good End Sub Private Sub skill1ExcellentOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill1ExcellentOption.CheckedChanged My.Settings.Skill1 = Skill.Excellent End Sub Private Sub skill2AverageOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill2AverageOption.CheckedChanged My.Settings.Skill2 = Skill.Average End Sub Private Sub skill2GoodOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill2GoodOption.CheckedChanged My.Settings.Skill2 = Skill.Good End Sub Private Sub skill2ExcellentOption_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles skill2ExcellentOption.CheckedChanged My.Settings.Skill2 = Skill.Excellent End Sub End Class Public Enum Skill None = 0 Average Good Excellent End Enum
Thanks jmcilhinney…:)
I appreciate your effort and time to help …:thumb:
I’ve tried to apply the codes on my project but unfortunately list of errors shows in “Error List” :confused:
Any idea Please… :ehh:
Best Regards…
Did you name your radio buttons "skill1GoodOption", "skill1ExcellentOption", "skill1AverageOption", ... as shown in JMC's code?
hi stanav...
After renaming radio buttons controls, I’m still getting some errors:
"Handles clause requires a WithEvents variable defined in the containing type or one of its base types."
So in this case this will result long list for radio buttons codes in load event & Subs ... :eek:
Any idea to avoid this case... :rolleyes:
Regards...
First up, why are your Settings declared as type Boolean? They need to be your enumeration type.
As for that error, you've done something wrong. You were NOT supposed to copy and paste my code. This is exactly why I avoid posting code on many occasions. My code was supposed to be an example only. You were supposed to write your own code. You were supposed to create CheckedChanged event handlers for your own RadioButtons and refer to your own RadioButtons in the Load event handler. If you have a lot of RadioButtons then you will have a lot of code. That's life.
Thanks jmcilhinney for your support…:)
For the setting declaration , I couldn’t see enumeration type in the list so I’m assuming it will be either string or system….,string collection and the values will be enum list ; is it?!
I’ve fixed my errors related with CheckedChanged event handlers; anyway using your codes example gives me better understanding of the work process for my project…
Best Regards…:wave:
Just curious about the enumeration type for settings. I don't seem to be able to set the setting type to my enumeration. Entering it into the textbox tells me the type is not defined?
Have you used the fully qualified name? For instance, if your project is called MyProject then the root namespace will also be MyProject by default. If you enumeration is called MyEnumeration and you have specified a namespace for it, it will be a member of the root namespace. As such, the fully qualified name is MyProject.MyEnumeration. You'll have to adjust that to use the actual names for you case. Plus, if you've changed the root namespace or added the type to a different namespace, which I doubt, then you'd have to adjust the fully qualified name accordingly.
Hi...
Enum Statement (Visual Basic)
Quote:
The Enum statement can declare the data type of an enumeration. Each member takes the enumeration's data type. You can specify Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort
With my project case it working only by above type list !
Regards...