Home All Groups Group Topic Archive Search About

radio button user settings

Author
16 Apr 2006 4:36 PM
Scuba Rob
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.

Author
16 Apr 2006 5:13 PM
Homer J Simpson
"Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
news:6F2E2D91-3681-41D4-93E4-30640DF991A1@microsoft.com...

> 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.
Author
16 Apr 2006 8:20 PM
Scuba Rob
Show quote Hide quote
"Homer J Simpson" wrote:

>
> "Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
> news:6F2E2D91-3681-41D4-93E4-30640DF991A1@microsoft.com...
>
> > 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.
>
>
>
> 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.
Author
17 Apr 2006 12:01 AM
Homer J Simpson
"Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
news:4777F681-13C2-4D21-8F94-62FC0C955C5A@microsoft.com...

> 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.
Author
17 Apr 2006 1:04 AM
Scuba Rob
OK, thanks Homer. I'll try this tomorrow

Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
> news:4777F681-13C2-4D21-8F94-62FC0C955C5A@microsoft.com...
>
> > 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.
>
>
>
>
Author
18 Apr 2006 12:54 AM
Scuba Rob
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

Show quoteHide quote
"Scuba Rob" wrote:

> OK, thanks Homer. I'll try this tomorrow
>
> "Homer J Simpson" wrote:
>
> >
> > "Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
> > news:4777F681-13C2-4D21-8F94-62FC0C955C5A@microsoft.com...
> >
> > > 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.
> >
> >
> >
> >
Author
18 Apr 2006 2:16 AM
Homer J Simpson
"Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
news:7F14B393-7962-46D3-9FF5-9325D8817876@microsoft.com...
> 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
Author
18 Apr 2006 11:20 AM
Scuba Rob
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

Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
> news:7F14B393-7962-46D3-9FF5-9325D8817876@microsoft.com...
> > 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
>
>
>
>
Author
18 Apr 2006 5:22 PM
Homer J Simpson
"Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
news:D2F3805D-D918-4DD7-B617-A0D376A06634@microsoft.com...

> 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).
Author
19 Apr 2006 2:53 AM
Scuba Rob
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

Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
> news:D2F3805D-D918-4DD7-B617-A0D376A06634@microsoft.com...
>
> > 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).
>
>
>
Author
19 Apr 2006 3:32 AM
Homer J Simpson
"Scuba Rob" <Scuba***@discussions.microsoft.com> wrote in message
news:6EE450A1-94C8-4B1E-9DB2-BB539F010EB4@microsoft.com...

> 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!