Link to home
Start Free TrialLog in
Avatar of Johnny
JohnnyFlag for United States of America

asked on

CheckState with checkbox how do i save the forms state(im reading/checking this from another form)

i have:
If (EMail_Options.Welcome_Msg.CheckState.Checked) Then

i found when i goto the form its on i check the box then close the form it disapers


how do i svae this state??

thx
Johnny
aka Pern
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ihenry
ihenry

Forgot to mention,
The Check_Clicked event is triggered when the checkbox is clicked.

Another things..my suggestion won't work if you're working on Windows Form... forgot to ask, my mistake..

Ok, if you're working on Windows Form

Declare one public shared variable in the form that contains the checkbox,

    Public Shared IsChecked As Boolean = False

And handle checked_changed event of the checkbox,

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        IsChecked = CheckBox1.Checked
    End Sub

And in another form, you can easily retrieve value from the variable

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim b As Boolean = Form1.IsChecked
    End Sub
Avatar of Johnny

ASKER

its on a windows form


its not working right. when i come back after ckloseing the form(its on an options tab [form1) its not checked..

how do i keep it the vlast value it is...

and then read it from your example [form2]

thx
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Johnny

ASKER

i figured it out...i saved the state to the registry and read it each time the form is opened this way i can check it in other areas as well...

im splitting the points as you both tryed to answer and i dont feel like asking for my points back...


heres how i did it for those who wish to know

https://www.experts-exchange.com/questions/21023595/Storing-data-in-the-registry.html

thx for the help as always
just thought of something

create a new module

then

private bCheck as boolean

public property chk() as boolean

Get
   reutrn bCheck
end get
set(byVal value as boolean)
    bCheck = value
end set

end property


and use myModule.chk to pass the value around...  This is how i do my Connextion strings after getting it from a encrypted string in the app.config

Anthoer idea, which i think is cleaner than registry..

Dave
Avatar of Johnny

ASKER

my problem is i am checking it from alot of other areas... and doing more then just the one check...

and i found i have to be on that form (the one that assigns the values) to have it work..if i save the values its a one time write and meny read type of thing...saving the values i can read the next time the forms open...

so the registery solution works really well...

thx for still trying...

Johnny
aka Pern