radio button user settings

G

Guest

I am having problems on getting the radio button to work with my.settings
correctly. I want the program to check to see which one was last saved to use
at startup. The closest I have come is that I need to click the radio button
twice for it to be saved correctly.
Any idea on what to use? I think the code should be fairly simple but I am
missing it for some reason.
 
H

Homer J Simpson

I am having problems on getting the radio button to work with my.settings
correctly. I want the program to check to see which one was last saved to
use
at startup. The closest I have come is that I need to click the radio
button
twice for it to be saved correctly.

Huh? You'd need to set a flag and persist that to reuse it.
 
G

Guest

Homer J Simpson said:
Huh? You'd need to set a flag and persist that to reuse it.



I save the new settings after clicking the other radio button. After clicking the radio button once the labels.text would update like it is supposed to but neither radio button would show as being selected. The second click would show the selected radio button andupon the next startup would correctly show as being correct.
Does this make any more sense? I'll post the code if you wish to see it.
 
H

Homer J Simpson

I save the new settings after clicking the other radio button. After
clicking the radio button once the labels.text would update like it is
supposed to but neither radio button would show as being selected. The
second click would show the selected radio button and upon the next
startup would correctly show as being correct.
Does this make any more sense? I'll post the code if you wish to see it.

Looks like there is something wrong with the radio button setup in that
case. Try creating a new solution with just the radio buttons and see if
they work OK.
 
G

Guest

OK, thanks Homer. I'll try this tomorrow

Homer J Simpson said:
Looks like there is something wrong with the radio button setup in that
case. Try creating a new solution with just the radio buttons and see if
they work OK.
 
G

Guest

Here is what I have for code but it still does not work. Any help would be
greatly appreciated:
Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
End
End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged
Call settings()
End Sub

Public Sub settings()
If RadioButton1.Checked = True Then
Me.Text = "Imperial"
My.Settings.Imperial = True
ElseIf RadioButton2.Checked = True Then
Me.Text = "Metric"
My.Settings.Metric = True
End If
My.Settings.Save()
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Call settings()
End Sub
End Class
 
H

Homer J Simpson

Scuba Rob said:
Here is what I have for code but it still does not work. Any help would be
greatly appreciated:

I put both buttons in a GroupBox.

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, _
RadioButton2.CheckedChanged
If RadioButton1.Checked = True Then
Me.Text = "Imperial"
Else
Me.Text = "Metric"
End If
End Sub
 
G

Guest

This part always worked fine. I need to store the radio button setting state
in the settings so upon startup it remembers which system to use, metric or
imperial. I have the Metric and Imperial setup in the settings as boolean.

Rob
 
H

Homer J Simpson

This part always worked fine. I need to store the radio button setting
state
in the settings so upon startup it remembers which system to use, metric
or
imperial. I have the Metric and Imperial setup in the settings as boolean.

Some have suggested that using a .ini file is easier and more reliable than
using the 'settings'. Or you could use the registry which is also pretty
reliable.

If you want to use My.Settings consider storing the state of 'Imperial' only
(True or False).
 
G

Guest

Homer,
I finally have got it to work using the My.Settings. Took me a few hours
playing with different settings but seems to work fine in the test
application.
Thanks for the help. I can send the code if anyone wants it.

Rob
 
H

Homer J Simpson

Homer,
I finally have got it to work using the My.Settings. Took me a few hours
playing with different settings but seems to work fine in the test
application.
Thanks for the help. I can send the code if anyone wants it.

OK. Quite a learning curve for us all on .Net!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top