problem with my.settings

  • Thread starter Thread starter Alcibiade
  • Start date Start date
A

Alcibiade

Hi, I have 2 questions about saving windows form settings.
I have a form with 1 textbox and 2 radiobuttons
I added application settings for :
textbox1, radiobutton1 and form location
I've set my.settings.save on form closing event.

I find :
-radiobutton doesn't remember its state but textbox remembers its
value
-if I minimize form then i close it by right menu, on next start it
won't show itself.
Any solutions?
Thanks.
 
Hi, I have 2 questions about saving windows form settings.
I have a form with 1 textbox and 2 radiobuttons
I added application settings for :
textbox1, radiobutton1 and form location
I've set my.settings.save on form closing event.

I find :
-radiobutton doesn't remember its state but textbox remembers its
value
-if I minimize form then i close it by right menu, on next start it
won't show itself.
Any solutions?
Thanks.

First right click on your app and go to settings then create 2
varibles named:

1)Radio1 as "boolean" type
2)Radio2 as "boolean" type
and leave value areas as blank or set true or false, doesn't matter.

This code works however you close your form, try:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
With My.Settings
RadioButton1.Checked = .Radio1
RadioButton2.Checked = .Radio2
End With
End Sub

Private Sub Form1_closing(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
With My.Settings
.Radio1 = RadioButton1.Checked
.Radio2 = RadioButton2.Checked
End With
End Sub

End Class

Meanwhile," off-topic" maybe it's a bug or not, if there's more than
one radio button on a form (eg: two radio buttons), although both of
their default "checked" values are false, always one of them(usually
first) is checked as runtime. Why?

Hope this helps.
 
kimiraikkonen said:
First right click on your app and go to settings then create 2
varibles named:

1)Radio1 as "boolean" type
2)Radio2 as "boolean" type
and leave value areas as blank or set true or false, doesn't matter.

This code works however you close your form, try:

It would be easier to just create those settings and then bind them to
RadioButtons' properties. There is (Application Settings) in Properties
window where Checked property can be bound to created setting. Now the
settings will be loaded and saved without any code.
Meanwhile," off-topic" maybe it's a bug or not, if there's more than
one radio button on a form (eg: two radio buttons), although both of
their default "checked" values are false, always one of them(usually
first) is checked as runtime. Why?

I think there must be one radio button checked in every panel or container.

-Teemu
 
I think there must be one radio button checked in every panel or container.

Maybe but this "problem" can be solved by setting radiobutton's
default value as "true" then back again "false" or something like
that. After playing with default menus and leaving both radio button's
"checked" value as "false" makes both radio buttons unchecked on
runtime by default.

However having one of radio buttons checked on form by default, may
apply pressure on user about selecting pre-selected radio button :-)
 
However having one of radio buttons checked on form by default, may
apply pressure on user about selecting pre-selected radio button :-)

It is the main idea that always one of the radio buttons is selected. In my
opinion it's against UI design guidelines to make all of them unchecked.

-Teemu
 
It would be easier to just create those settings and then bind them to
RadioButtons' properties. There is (Application Settings) in Properties
window where Checked property can be bound to created setting. Now the
settings will be loaded and saved without any code.

Ithink it's a fast way binding settings to radiobutton's properties
but it doesn't work good!! I've 2 radiobuttons associated with 2
different settings. To select a different radiobutton I have to select
twice same radiobutton: for example, by first click the firts
radiobutton become unchecked, by second click the second radiobutton
become checked....
 
Back
Top