Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
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.
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
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.
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
Originally Posted by DragonRose
You could go to the properties for each radiobutton, and on the 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,.
Thanks DragonRose for reply...
I was looking for Simplified solution for this issue because using application settings and property binding will result quit a long list for each control !
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
Originally Posted by jmcilhinney
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.
Thanks jmcilhinney…
How can I store the values after defining an enumeration?
Code:
Public Enum Skill
Rad_Average = 1
Rad_good = 2
Rad_Excellent = 3
End Enum
Could you PLZ give me an example in codes with my issue ?!
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
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.
Last edited by jmcilhinney; May 31st, 2010 at 06:13 PM.
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
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.
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
Originally Posted by jmcilhinney
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…
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
Originally Posted by HOTFIX
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?!
The list contains the most common options, plus a Browse option if you want to use something else. You can then either select your type from the tree or just enter it directly into the text box.
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
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?
Re: How to save setting for radio buttons & Checkboxes control in groupboxes ?!
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.
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 !